[关闭]
@jeffjade 2016-02-18T17:06:52.000000Z 字数 777 阅读 1415

扑腾npm之折腾记

Node.js


How to set NODE_ENV to production/development in OS X

  1. "scripts": {
  2. "dev": "webpack-dev-server --inline --hot --quiet",
  3. "build": "SET NODE_ENV=production && webpack --progress --hide-modules"
  4. }

在以vue+webpack折腾web前端开发时,作package.json配置,当需要了解,node环境在Mac和Windows设置是有区别的,详情可参见stackoverflow的回答:

Before running your app, you can do this in console (Mac),

  1. export NODE_ENV=production

Or if you are in windows you could try this:

  1. SET NODE_ENV=production

or you can run your app like this:

  1. NODE_ENV=production node app.js

You can also set it in your js file:

  1. process.env.NODE_ENV = 'production';

But I don't suggest to do it in your runtime file, since it's not easy to open up VIM in your server and change it to production. You can make a config.json file in your directory and everytime your app runs, it reads from it and sets the configuration.

How to set NODE_ENV to production/development in OS X

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注