undefined is not an object (evaluating ‘process.env.NODE_ENV’)

  node.js, question

The npm environment was successfully started, but an error was reported on the browser:

TypeError: undefined is not an object (evaluating 'process.env.NODE_ENV')
keyMirror - keyMirror.js:38

View: keyMirror:

/**
 * Constructs an enumeration with keys equal to their value.
 *
 * For example:
 *
 *   var COLORS = keyMirror({blue: null, red: null});
 *   var myColor = COLORS.blue;
 *   var isColorValid = !!COLORS[myColor];
 *
 * The last line could not be performed if the values of the generated enum were
 * not equal to their keys.
 *
 *   Input:  {key1: val1, key2: val2}
 *   Output: {key1: key1, key2: key2}
 *
 * @param {object} obj
 * @return {object}
 */
var keyMirror = function(obj) {
  var ret = {};
  var key;
  ("production" !== process.env.NODE_ENV ? invariant(
    obj instanceof Object && !Array.isArray(obj),
    'keyMirror(...): Argument must be an object.'
  ) : invariant(obj instanceof Object && !Array.isArray(obj)));
  for (key in obj) {
    if (!obj.hasOwnProperty(key)) {
      continue;
    }
    ret[key] = key;
  }
  return ret;
};

module.exports = keyMirror;

Later, it was discovered that the problem was configured in webpack inside:

loaders: [{
 test: /\.jsx?  $/,
 loaders: ['react-hot', 'babel'],
 include: path.resolve(ROOT_PATH, 'app/src')
 bracket
 ...
 bracket

Addinclude: path.resolve(ROOT_PATH, 'app/src')Just limit the scope of analysis.
Presumably, it can also speed up.