错误:WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'product......

解决方法一

在看到很多旧教程上教的webpack的cli操作
webpack ./app.js bundle.js

但是如果现在用webpack再次操作的话,会报错
ERROR in Entry module not found: Error: Can't resolve 'main.js' in 'D:\SELFINTRODUCE\src'

查了一下官方文档才得知,webpack的打包cli命令已经更改:
webpack [] -o
同学们不要弄错哦!

 

解决方法二

1、错误描述

WARNING in 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/

2、错误原因

没有设置webpack的模式,是生产还是开发(production or development)

3、解决办法

执行命令:webpack --mode=production 或者 webpack --mode=development

$ ./node_modules/.bin/webpack --mode=development

Hash: 310a9d712d610fa38fef
Version: webpack 4.17.2
Time: 743ms
Built at: 2018-09-05 16:06:05
  Asset      Size  Chunks             Chunk Names
main.js  3.81 KiB    main  [emitted]  main
Entrypoint main = main.js
[./src/index.js] 37 bytes {main} [built]

 

转载于:https://my.oschina.net/jamesview/blog/3089886

你可能感兴趣的:(错误:WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'product......)