title: Pass environment variable from command line to yarn
body: <p>I have a code that reads port number from environment variable or from config. Code looks like this</p>
  
  <pre><code>const port = process.env.PORT || serverConfig.port;
  await app.listen(port);
  </code></pre>
  <p>To run app without defining environment variable, I run following yarn command.</p>
  <blockquote>
  <p><code>yarn start:dev</code></p>
  </blockquote>
  <p>This command works successfully in Linux shell and Windows command line.</p>
  <p>Now, I want to pass environment variable. I tried following,</p>
  <blockquote>
  <p><code>PORT=2344 yarn start:dev</code></p>
  </blockquote>
  <p>This commands works successfully in Linux shell but failing in Windows command line. I tried following ways but couldn't get it to work.</p>
  <p>Tried: PORT=2344 yarn start:dev</p>
  <p>I got error: 'PORT' is not recognized as an internal or external command,
  operable program or batch file.</p>
  <p>Tried: yarn PORT=2344 start:dev</p>
  <p>I got error: yarn run v1.17.3
  error Command &quot;PORT=2344&quot; not found.
  info Visit <a href="https://yarnpkg.com/en/docs/cli/run" rel="noreferrer">https://yarnpkg.com/en/docs/cli/run</a> for documentation about this command.</p>
  <p>Any idea please? I know, I can define environment variables from System Properties in Windows. But any way if I can do it from command line?</p>