我是nodejs的新手并安装了它。但是 npm start 命令对我来说并不成功。它显示错误
Posted
技术标签:
【中文标题】我是nodejs的新手并安装了它。但是 npm start 命令对我来说并不成功。它显示错误【英文标题】:i am new to nodejs and installed it. But npm start command is not success for me. It is showing the errors 【发布时间】:2021-01-28 23:58:40 【问题描述】:我是 nodejs 的新手并安装了它。但是 npm start 命令对我来说并不成功。它显示错误
C:\Users\Om Namah Shiavay\reactjs>npm start
我在这里运行命令
> reactjs@1.0.0 start C:\Users\Om Namah Shiavay\reactjs
> webpack-dev-server --mode development --open --hot
internal/modules/cjs/loader.js:834
throw err;
^
错误从这里开始
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\Om Namah Shiavay\reactjs\node_modules\webpack-dev-server \bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Users\Om Namah Shiavay\reactjs\node_modules \webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules /cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js
:60:12)
此文件存在于文件夹中
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Om Namah Shiavay\\reactjs\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs@1.0.0 start: `webpack-dev-server --mode development --open --ho
t`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs@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\Om Namah Shiavay\AppData\Roaming\npm-cache\_logs\2020-10-1
5T14_54_15_617Z-debug.log
C:\Users\Om Namah Shiavay\reactjs>npm install --save-dev webpack-dev-server ^Ar
【问题讨论】:
错误清楚地说:Error: Cannot find module 'webpack' 这能回答你的问题吗? Error: Cannot find module 'webpack' 但是 webpack 安装在“node_modules”文件夹中 【参考方案1】:尝试删除 node_modules 和 package-lock.json,然后重新安装包(在您的 powershell 上运行以下命令)
rm node_modules -r -force
rm package-lock.json
npm cache verify
npm install
【讨论】:
以上是关于我是nodejs的新手并安装了它。但是 npm start 命令对我来说并不成功。它显示错误的主要内容,如果未能解决你的问题,请参考以下文章