[樂意黎原創]npm run dev 時拋'cross-env' is not recognized as an internal or external command的解決方法

通過 Vue init webpack-simple 創建工程中,  運行 npm run dev 時拋以下錯誤,

 cross-env NODE_ENV=development webpack-dev-server --open --hot

'cross-env' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aerchi\AppData\Roaming\npm-cache\_logs\2020-03-24T18_46_51_349Z-debug.log

解決方法: 

webpack打包報錯,原因是windows不支持 cross-env,安裝模塊即可:

npm install -g  cross-env

cnpm install -g  cross-env
--------------------------------
First, run:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force

Then run the command

npm install cross-env

npm install 

and then you can also run

npm run dev
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章