Closed tbo closed 9 years ago
Totally +1.
I'm currently testing to render react components on server-side and when I require react I got the error that process is undefined
or cannot read property NODE_ENV
of undefined.
It's a pretty easy fix and could even be injected through an API (setNodeEnv, or something like that).
We could certainly add this, but unless react is specifically designed to only run on Node.js then I'd consider this a bug in react. Have you tried submitting a bug report with them?
I've added process.env anyway so as not to block you :)
Thanks alot Tim.
In fact I think it's a matter of what is under the scope of "pure" npm (if it even makes sense) dependency and node-dependency.
The react I'm trying to require has been installed under node-modules, so I think it's logical the module is expecting a node environment.
Anyway, thanks, we'll be able to use node modules which is really interesting.
A lot of popular npm packages (i.e. react, superagent) are accessing process.env.NODE_ENV in order to deduce if and how they should handle debugging related tasks. Apparently you are using jvm-npm. Based on my experience with vert.x 2, it would suffice to define process.env before loading jvm-npm. In vert.x 2 it would look like this:
It would probably be even better, if we could read out the actual value of NODE_ENV. But the API for accessing environment variables was changed and the new one is not documented yet.