Wednesday, 15 April 2015

javascript - React + webpack: 'process.env' is undefined -


I am trying to run hot dev server on our site with webpac; The site uses ReactJS, in which it contains the code:

  if (\ "production \"! == process.env.NODE_ENV) // etc  

It is fine while not running hot-swap, but with hot-swap, it starts running, which may result in error:

  TypeError: process.env is undefined < / Code> 

The code looks like this:

error on this line

The format of the project is prepared after which does work Receives; So the question is;

I have deployed.

Div class = "post-text" itemprop = "text">

In your webpage configuration, there are two options which can affect process.env :

    < Li> (see)

Looking at your code, it seems that process.env can be redefined Options.prerender and options.minimize are false .

You can always fix it by using an environment that is process.env (ex: node ), or a default value for yourself By assigning DefinePlugin to assign


No comments:

Post a Comment