kit chan kit chan - 1 year ago 154
Node.js Question

envify in react.js doesn't work

I am new to node.js and react.js.
I recently learn react.js and follow the instruction on react.js offical page and try to use production mode.
So i start with the code in main.js

var React = require('react');
var ReactDOM = require('react-dom');

<h1>Hello, world!</h1>,

and browserify it

$ browserify -t [ babelify --presets [ react ] ] -t [ envify --NODE_ENV production ] main.js -o bundle.js

But envify seems not work. The result bundle code still contain


Is something wrong? I 've tried to set
in the main.js. But it doesnt work. can anyone help me? thanks.

Answer Source

Set the NODE_ENV variable in the shell instead.

NODE_ENV=production browserify -t [ babelify --presets [ react ] ] -t envify main.js -o bundle.js
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download