简体   繁体   English

当我试图打开我的反应应用程序时,CMD 显示 npm 错误:说'npm err? 缺少脚本:开始'任何人都可以帮助我吗?

[英]While i am trying to open my react app the CMD showing an npm err! Saying 'npm err! missing script:start' can anyone help me?

enter image description here在此处输入图像描述

I've searched in previous answers and tried to solve this for many hours but with no success.我已经搜索了以前的答案并试图解决这个问题好几个小时但没有成功。 I've typed in the terminal npm create-react-app, moved to the correct cd, and it gives me this error:我在终端 npm create-react-app 中输入,移动到正确的 cd,它给了我这个错误:

'npm ERR: missing script: start' 'npm ERR:缺少脚本:开始'

Start by validating that the 'start' script exists inside the package.json.首先验证 package.json 中是否存在“启动”脚本。 That's where the script gets invoked.这就是脚本被调用的地方。 It should be under the key "scripts".它应该在关键的“脚本”下。 If it's not there then that's the problem.如果它不存在,那就是问题所在。

Should look something like this (if using react-scripts dependency):应该看起来像这样(如果使用 react-scripts 依赖项):

"scripts": {
    "start": "react-scripts start",
    ....
}

And if you're missing dependencies then run the following command inside the project directory to install them:如果您缺少依赖项,请在项目目录中运行以下命令来安装它们:

npm install

You should ensure that you have package.json in your project and it has the command start registered in it, example您应该确保您的项目中有 package.json 并且其中注册了命令start ,例如

"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"

}, },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM