Module build failed: TypeError: Cannot read property ‘NODE_ENV’ of undefined

The Error message:

index.bundle.js?f5a3506…:32 ./Content/css/bootstrap.min.css
Module build failed: TypeError: Cannot read property 'NODE_ENV' of undefined
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:2672:17)
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:2706:28)
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:2707:31)
    at __webpack_require__ (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:519:30)
    at fn (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:50:20)
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:2335:16)
    at Object.module.exports.ReactCurrentOwner.current (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:2605:31)
    at __webpack_require__ (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:519:30)
    at fn (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:50:20)
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:1959:21)
    at __webpack_require__ (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:519:30)
    at fn (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:50:20)
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:1645:22)
    at Object.<anonymous> (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:1717:31)
    at __webpack_require__ (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:519:30)
    at fn (C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\node_modules\css-loader\index.js!C:\Users\msi\Desktop\ww\react-webpack-es6-bootstrap\Content\css\bootstrap.min.css:50:20)
 @ ./Scripts/entry.js 31:0-43

After I run the code

npm run dev

then,all the css file had this error.

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev":"SET NODE_ENV=development&& node webpack.config.server.js",
    "build": "set NODE_ENV=production&& webpack -p --progress"
  },

Could anyone tell me the reason ?

Author: Fantashit

1 thought on “Module build failed: TypeError: Cannot read property ‘NODE_ENV’ of undefined

  1. It’s probably expecting process so you might want to set

    plugins: [
      new webpack.DefinePlugin({
        'process.env.NODE_ENV': process.env.NODE_ENV
      })
    ]

    or so.

    Also EnvironmentPlugin would work.

    Can you re-open at Stack Overflow for a better response? Thanks.

Comments are closed.