在本項目目錄下輸入: npm i webpack-dev-server報錯
報錯的提示如下:
npm WARN [email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
我的解決方法:
方法一:
- 在當前項目下輸入:
//在本地下載安裝webpack-cli
npm i webpack-cli -D
- 再在當前目錄下輸入:
//在本地下載安裝webpack-dev-server
npm i webpack-dev-server -D
輸入npm run dev啓動項目若報錯提示爲:
(能輸入npm run dev 要確保package.json中的配置有一項是這樣的:
)
根據報錯提示可知是沒有找到webpack, 那我們在項目下再本地安裝webpack即可:
npm i webpack -D
然後重新輸入:
npm run dev
問題解決!!
方法二:
安裝低版本的webpack-cli, 由於我的已經用上面的方法解決了, 這種方法是參考網上的解決方案
//安裝3.0.0版本的webpack-cli, 當然也可以指定其他版本
npm i [email protected]
多嘗試, 不要灰心, 總有解決的辦法的!!