npm run dev--The 'mode' option has not been set, webpack will fallback to 'production
Posted 林肯公园
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了npm run dev--The 'mode' option has not been set, webpack will fallback to 'production相关的知识,希望对你有一定的参考价值。
npm run dev时报警告:
warning
configuration
The ‘mode‘ option has not been set, webpack will fallback to ‘production‘ for this value. Set ‘mode‘ option to ‘development‘ or ‘production‘ to enable defaults for each environment.
You can also set it to ‘none‘ to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/
升级webpack4.0后,打包报如下错误:
WARNING in configuration
The ‘mode‘ option has not been set, webpack will fallback to ‘production‘ for thisvalue. Set ‘mode‘ option to ‘development‘ or ‘production‘ to enable defaults for each environment.
You can also set it to ‘none‘ to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/
webpack官网更新日志有说明:webpack升级4.0新增mode属性
1
解决方法:
1.package.json中设置:
"scripts": { "dev": "webpack --mode development", // 开发环境 "build": "webpack --mode production", // 生产环境 },
2.webpack.config.js中设置:
module.exports = { entry: ‘./src/app.js‘, output: { path: path.resolve(__dirname, ‘dist‘), filename: ‘main.js‘ }, mode: ‘development‘ // 设置mode }
下载指定webpack指定版本:
npm i -D [email protected] // 3: webpack版本3最新
以上是关于npm run dev--The 'mode' option has not been set, webpack will fallback to 'production的主要内容,如果未能解决你的问题,请参考以下文章
npm run dev报错--Error: Cannot find module 'yargs-parser'
npm run dev报错,events.js:160 throw er; // Unhandled 'error' event
使用vue-cli初始化项目时运行‘npm run dev’报错
当使用npm run build的时候报错:TypeError: Cannot read property 'thisCompilation' of undefined
vue工程npm run serve时启动报:Cannot read property 'range' of null 错误