npm 没有启动。错误:找不到模块“webpack-cli/bin/config-yargs”
Posted
技术标签:
【中文标题】npm 没有启动。错误:找不到模块“webpack-cli/bin/config-yargs”【英文标题】:npm not start. Error: Cannot find module 'webpack-cli/bin/config-yargs' 【发布时间】:2021-08-10 18:22:59 【问题描述】:当我给 npm start 命令和它的显示 内部/模块/cjs/loader.js:883 抛出错误: 错误:找不到模块'webpack-cli/bin/config-yargs' 请帮我解决这个问题 使用操作系统:Windows 10 节点版本为 v14.16.1
> chapter15.1@1.0.0 start
> webpack-dev-server
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\user\Desktop\JS full Course\chapter15.1\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\user\Desktop\JS full Course\chapter15.1\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\user\\Desktop\\JS full Course\\chapter15.1\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
webpack 版本 5.37.1 webpack-cli 版本 4.7.0 webpack-dev-server 版本 3.11.2
Package.json 文件是
"name": "chapter15.1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts":
"start": "webpack-dev-server"
,
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies":
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@babel/node": "^7.14.2",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.14.2",
"@babel/register": "^7.13.16",
"babel-loader": "^8.2.2",
"babel-register": "^6.26.0",
"html-webpack-plugin": "^5.3.1",
"webpack": "^5.37.1",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^3.11.2"
【问题讨论】:
【参考方案1】:-
在
Package.json
文件中添加serve
脚本,如下所示并删除start
脚本。 See the documentation.
"scripts":
"serve": "webpack serve"
,
-
然后在终端中运行此命令。
npm run serve
【讨论】:
以上是关于npm 没有启动。错误:找不到模块“webpack-cli/bin/config-yargs”的主要内容,如果未能解决你的问题,请参考以下文章
如何修复错误“找不到此相关模块:* ./src/main.js in multi (webpack)-dev-server”在 npm run serve in vue3.x with typescr
如何修复material-kit-react'找不到模块:webpack loader错误'
将常规 npm 包加载到 webpack/angular cli [找不到模块]