简体   繁体   English

npm 启动命令在反应应用程序中给出错误

[英]npm start command giving error in react app

i used npx create-react-app basic and the react app was created.我使用了 npx create-react-app basic 并创建了反应应用程序。 I then went into the basic folder and tried npm start but it gave me the following error:然后我进入基本文件夹并尝试npm start但它给了我以下错误:

 npm start basic@0.1.0 start C:\Users\91982\Desktop\html&css\React\basic react-scripts start 'css\React\basic\node_modules\.bin\' is not recognized as an internal or external command, operable program or batch file. internal/modules/cjs/loader.js:985 throw err; ^ Error: Cannot find module 'C:\Users\91982\Desktop\react-scripts\bin\react-scripts.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15) at Function.Module._load (internal/modules/cjs/loader.js:864:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } npm ERR. code ELIFECYCLE npm ERR. errno 1 npm ERR: basic@0.1.0 start. `react-scripts start` npm ERR. Exit status 1 npm ERR. npm ERR: Failed at the basic@0:1.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\91982\AppData\Roaming\npm-cache\_logs\2020-06-10T19_54_37_385Z-debug.log

I even tried creating the app with npm but it gave me the same error.我什至尝试使用 npm 创建应用程序,但它给了我同样的错误。 The start script is present in the json file. start脚本存在于 json 文件中。 npm is updated to the latest version. npm 更新到最新版本。

You can try the following:您可以尝试以下方法:

  • cd to your project directory (Make sure there is a package.json file) cd 到您的项目目录(确保有 package.json 文件)
  • delete node_modules directory删除 node_modules 目录
  • npm install && npm start npm 安装 && npm 启动

try this尝试这个

Goto > Control Panel\System and Security\System\Advance system setting\Enviroment variable and set system variables path C:\Windows\System32\ variable and restart your System.转到 > 控制面板\系统和安全\系统\高级系统设置\环境变量并设置系统变量路径 C:\Windows\System32\ 变量并重新启动系统。

after restarting it will work 100%..重新启动后它将工作100%..

thanks谢谢

It appears you didn't install the dependencies.看来您没有安装依赖项。 Run npm i or npm install to install the dependencies.运行npm inpm install安装依赖项。 It's not finding the react-scripts module because it wasn't installed.它没有找到 react-scripts 模块,因为它没有安装。

I think it is an issue with your Windows PATH environment variable.我认为这是您的 Windows PATH 环境变量的问题。 It is trying to execute something in the local project node_modules directory, but windows cant find it because it is not in the path.它试图在本地项目 node_modules 目录中执行某些操作,但 windows 找不到它,因为它不在路径中。

You can try using the npx command instead of npm .您可以尝试使用npm npx

npx start

Npx checks the PATH and local project binaries for executable. Npx 检查 PATH 和本地项目二进制文件的可执行文件。

  1. npm install create-react-app -g npm install create-react-app -g
  2. cd you project folder cd 你的项目文件夹
  3. delete node_modules folder删除 node_modules 文件夹
  4. npm install && npm start npm 安装 && npm 启动

I solved the issue.我解决了这个问题。 I had to add C:/Windows/Systen32 to my system variables Path.我必须将 C:/Windows/Systen32 添加到我的系统变量路径中。 It started working after that.之后它开始工作。

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

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