webpack安裝大於4.x版本(沒有配置webpack.config.js)
如果安裝的webpack版本大於4+,還需要安裝webpack-cli.在沒有配置webpack.config.js之前,還需要配置輸出參數
webpack ./src/main.js ./dist/bundle.js //沒有配置輸出參數 -o

/沒有配置輸出參數 -o
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/configuration/mode/
ERROR in multi ./src/main.js ./dist/bundle.js
Module not found: Error: Can't resolve './dist/bundle.js' in 'D:....\webpack-test2'
@ multi ./src/main.js ./dist/bundle.js main[1]
要解決這個問題,在打包指令中加入-o即

配置輸出參數 -o
webpack ./src/main.js -o ./dist/bundle.js //加入-o指令
webpack ./src/main.js -o ./dist/bundle.js //加入--mode development可去掉屎黃色的警告
最好的解決方案:選擇低於4.0的版本,無需安裝webpack-cli,且可以直接輸入輸出
webpack ./src/main.js ./dist/bundle.js

低版本webpack打包