For use in express.js environments. Any suggestions?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
If you are on windows. Open your cmd at right folder then first
hit enter then you can start your node with
it will start with your env setting
in package.json:
then run in terminal:
export NODE_ENV=production
is bad solution, it disappears after restart.if you want not to worry about that variable anymore - add it to this file:
don't use export syntax, just write (in new line if some content is already there):
it works after restart. You will not have to re-enter export NODE_ENV=production command anymore anywhere and just use node with anything you'd like - forever, pm2...
For heroku:
which is actually default.
Windows CMD ->
set NODE_ENV=production
Windows Powershell ->
$env:NODE_ENV="production"
MAC ->
export NODE_ENV=production
On OSX I'd recommend adding
export NODE_ENV=development
to your~/.bash_profile
and/or~/.bashrc
and/or~/.profile
.Personally I add that entry to my
~/.bashrc
and then have the~/.bash_profile
~/.profile
import the contents of that file, so it's consistent across environments.After making these additions, be sure to restart your terminal to pick up settings.