Javascript 本地 package.json 存在,但缺少 node_modules

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50355263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 04:35:36  来源:igfitidea点击:

Local package.json exists, but node_modules missing

javascriptreactjsnpmreduxreact-redux

提问by Deepak Mahakale

I am trying to start a Redux application I just cloned from a GitHub repository.

我正在尝试启动我刚刚从 GitHub 存储库克隆的 Redux 应用程序。

I tried to run it with the following command

我尝试使用以下命令运行它

npm start

I am getting this error

我收到此错误

> [email protected] start /home/workspace/assignment
> webpack-dev-server --config ./configs/webpack/webpack.config.development.js

sh: 1: webpack-dev-server: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: `webpack-dev-server --config ./configs/webpack/webpack.config.development.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/.npm/_logs/2018-05-15T16_32_44_571Z-debug.log

Any help will be appreciated

任何帮助将不胜感激

回答by Dan

npm startruns a script that the app maker built for easy starting of the app npm installinstalls all the packages in package.json

npm start运行应用程序制造商为轻松启动应用程序而构建的脚本 npm install安装 package.json 中的所有包

run npm installfirst

npm install第一

then run npm start

然后运行 npm start

回答by Malisha Tharindu

'npm WARN Local package.json exists, but node_modules missing, did you mean to install?'

to resolve this error message you have to install npm package that will installs all the required packages first. Therefore before run npm startyou have to run npm installat first.

要解决此错误消息,您必须安装 npm 包,该包将首先安装所有必需的包。因此,在运行npm start之前,您必须首先运行npm install

回答by Codiee

This issue can also raise when you change your system password but not the same updated on your .npmrcfile that exist on path C:\Users\user_name, so update your password there too.

当您更改系统密码但在路径C:\Users\user_name上存在的.npmrc文件上的更新不相同时,也会出现此问题,因此也请更新您的密码。

please check on it and run npm install first and then npm start.

请检查它并先运行 npm install 然后运行 ​​npm start。

回答by Zanon

Just had the same error message, but when I was running a package.json with:

只是有相同的错误消息,但是当我运行 package.json 时:

"scripts": {
    "build": "tsc -p ./src",
}

tscis the command to run the TypeScript compiler.

tsc是运行 TypeScript 编译器的命令。

I never had any issues with this project because I had TypeScript installed as a global module. As this project didn't include TypeScript as a dev dependency (and expected it to be installed as global), I had the error when testing in another machine (without TypeScript) and running npm installdidn't fix the problem. So I had to include TypeScript as a dev dependency (npm install typescript --save-dev) to solve the problem.

我从来没有遇到过这个项目的任何问题,因为我将 TypeScript 安装为全局模块。由于该项目不包含 TypeScript 作为开发依赖项(并希望将其安装为全局),因此在另一台机器(没有 TypeScript)上测试时出现错误并且运行npm install没有解决问题。所以我不得不将 TypeScript 作为开发依赖项 ( npm install typescript --save-dev) 来解决这个问题。