简体   繁体   中英

Getting error while creating a react project

This appears:

Creating a new React app in C:\\Program Files\\nodejs\\my-app .

'npm' is not recognized as an internal or external command, operable program or batch file.

Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...

'npm' is not recognized as an internal or external command, operable program or batch file. events.js:174 throw er; // Unhandled 'error' event ^

Error: spawn npm ENOENT at notFoundError (C:\\Users\\russu\\AppData\\Roaming\\npm-cache_npx\\9700\\node_modules\\create-react-app\\node_modules\\cross-spawn\\lib\\enoent.js:11:11) at verifyENOENT (C:\\Users\\russu\\AppData\\Roaming\\npm-cache_npx\\9700\\node_modules\\create-react-app\\node_modules\\cross-spawn\\lib\\enoent.js:46:16) at ChildProcess.cp.emit (C:\\Users\\russu\\AppData\\Roaming\\npm-cache_npx\\9700\\node_modules\\create-react-app\\node_modules\\cross-spawn\\lib\\enoent.js:33:19) at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) Emitted 'error' event at: at ChildProcess.cp.emit (C:\\Users\\russu\\AppData\\Roaming\\npm-cache_npx\\9700\\node_modules\\create-react-app\\node_modules\\cross-spawn\\lib\\enoent.js:36:37) at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

PS: i have node.js, i have a path variable i have everything installed, why its not working while using create-react-app and npm its nort recognized, idu!!!!

Did you reload your PC? Here some steps which should be done to make it work:

  1. Go to MyComputer->Settings->AdditionalSettings->EvnvironmentVariables
  2. Find 'Path' in the list, click 'Change'
  3. Add path to nodejs folder
  4. Reload PC
  5. Check in cmd npm --version

在此输入图像描述

I have faced similar issue, and this works for me.

  1. edit package.json so the new version of react-scripts is "2.1.8"
  2. npm install
  3. cd my-app
  4. npm start

    Source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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