Skip to main content
added 206 characters in body
Source Link
lorless
  • 4.6k
  • 8
  • 33
  • 47

A bit of background, on mac you can do something like this

PORT=3002 NODE_ENV=dev node server.js 

But can you do the same on windows? I have tried

set PORT=3002 && echo %PORT% 

but the variable does not update until the echo is called again.

The reason I need this is that i am currently using npm start to run a script on a mac that looks like the first line of code. This does not work in windows since you cannot set env variables like that.

A bit of background, on mac you can do something like this

PORT=3002 NODE_ENV=dev node server.js 

But can you do the same on windows? I have tried

set PORT=3002 && echo %PORT% 

but the variable does not update until the echo is called again.

A bit of background, on mac you can do something like this

PORT=3002 NODE_ENV=dev node server.js 

But can you do the same on windows? I have tried

set PORT=3002 && echo %PORT% 

but the variable does not update until the echo is called again.

The reason I need this is that i am currently using npm start to run a script on a mac that looks like the first line of code. This does not work in windows since you cannot set env variables like that.

Source Link
lorless
  • 4.6k
  • 8
  • 33
  • 47

How can I set and use an environment variable in windows cmd in the same line?

A bit of background, on mac you can do something like this

PORT=3002 NODE_ENV=dev node server.js 

But can you do the same on windows? I have tried

set PORT=3002 && echo %PORT% 

but the variable does not update until the echo is called again.