Reputation: 1819
When webpack bundles and I launch the website, I get the following error:
*** process.env.ENV is not defined, assuming 'prod' env
However, if I log my process.env
Object {NODE_ENV: "development", ENV: "development", HOST: "localhost"}
My webpack configuration:
/* Main */
const webpackConfig = {
entry: [
project.app.entry,
],
output: {
path: project.path.out,
filename: 'bundle.js',
publicPath: '/',
},
module: {
rules: [{
test: /\.js$/,
include: project.path.app,
exclude: /node_modules/,
use: [
{ loader: 'babel-loader' },
{ loader: 'eslint-loader' },
],
}],
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
ENV: JSON.stringify(process.env.NODE_ENV),// Added because webpack bundle complains
HOST: JSON.stringify(process.env.HOST),
},
}),
],
devtool: DEV ? 'source-map' : false,
resolve: {
modules: ["src", "node_modules"],
alias: {}
}
};
Is this a bug in webpack, or am I missing something? Thank you.
Upvotes: 2
Views: 612
Reputation: 11661
Some people are having the same issue because of the Grammarly extension.
If you are using it, disable it and the error will be gone.
Related:
How to define process.env.ENV in create-react-app?
*** process.env.ENV is not defined, assuming 'prod' env
https://github.com/facebookincubator/create-react-app/issues/2722
Upvotes: 2