React In Action · 工具鏈 · webpack Cannot find module 'webpack-cli/bin/config-yargs'

一、npm start 異常

D:\CodePractice\2021\00_BoilerPlate>npm start

> 00_boilerplate@1.0.0 start D:\CodePractice\2021\00_BoilerPlate

> webpack-dev-server? --mode development --inline --hot --open

internal/modules/cjs/loader.js:589

? ? throw err;

? ? ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'

? ? at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)

? ? at Function.Module._load (internal/modules/cjs/loader.js:513:25)

? ? at Module.require (internal/modules/cjs/loader.js:643:17)

? ? at require (internal/modules/cjs/helpers.js:22:18)

? ? at Object.<anonymous> (D:\CodePractice\2021\00_BoilerPlate\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)

? ? at Module._compile (internal/modules/cjs/loader.js:707:30)

? ? at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)

? ? at Module.load (internal/modules/cjs/loader.js:605:32)

? ? at tryModuleLoad (internal/modules/cjs/loader.js:544:12)

? ? at Function.Module._load (internal/modules/cjs/loader.js:536:3)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! 00_boilerplate@1.0.0 start: `webpack-dev-server? --mode development --inline --hot --open`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the 00_boilerplate@1.0.0 start 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\sinwaj\AppData\Roaming\npm-cache\_logs\2021-03-21T07_26_42_987Z-debug.log

二、package.json版本信息

"dependencies": {

? ? "webpack-cli": "^4.5.0",

? ? "webpack-dev-server": "^3.11.2"

? }

三、降級webpack-cli

4.5.0降級到3.3.12

1.D:\CodePractice\2021\00_BoilerPlate>npm uninstall webpack-cli

2.D:\CodePractice\2021\00_BoilerPlate>npm install webpack-cli@^3.3.12

四、重新啟動

D:\CodePractice\2021\00_BoilerPlate>npm start

> 00_boilerplate@1.0.0 start D:\CodePractice\2021\00_BoilerPlate

> webpack-dev-server? --mode development --inline --hot --open

i ?wds?: Project is running at http://localhost:8080/

i ?wds?: webpack output is served from /

i ?wds?: Content not from webpack is served from ./dist

i ?atl?: Using typescript@4.2.3 from typescript

i ?atl?: Using tsconfig.json from D:/CodePractice/2021/00_BoilerPlate/tsconfig.json

WARNING (@babel/preset-env): We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.

You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:

? npm install --save core-js@2? ? npm install --save core-js@3

? yarn add core-js@2? ? ? ? ? ? ? yarn add core-js@3

More info about useBuiltIns: https://babeljs.io/docs/en/babel-preset-env#usebuiltins

More info about core-js: https://babeljs.io/docs/en/babel-preset-env#corejs

i ?wdm?: wait until bundle finished: /

i ?atl?: Checking started in a separate process...

i ?atl?: Time: 717ms

i ?wdm?: Compiled successfully.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容