0

when i install create -react-app i come upon an error this is the error code i got

first i try installing by running this command npx create-react-app my-app then i got 'create-react-app' is not recognized as an internal or external command, operable program or batch file.

Need to install the following packages:
  create-react-app
Ok to proceed? (y) y
'create-react-app' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Ela EKİZ\Desktop\create-react-app>npm start

> start
> cd packages/react-scripts && node bin/react-scripts.js start

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'react-dev-utils/crossSpawn'
Require stack:
- C:\Users\Ela EKİZ\Desktop\create-react-app\packages\react-scripts\bin\react-scripts.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\Ela EKİZ\Desktop\create-react-app\packages\react-scripts\bin\react-scripts.js:18:15)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Ela EKİZ\\Desktop\\create-react-app\\packages\\react-scripts\\bin\\react-scripts.js'
  ]
}```
Zzz
  • 1
  • 1

3 Answers3

0
  1. Delete the whole folder including node_modules.

  2. Run npm install again.

Good luck.

SunAider
  • 1
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 09 '22 at 10:38
  • how can i delete the whole folder – Zzz Apr 09 '22 at 10:58
0

As the information provided, i didn't get the idea like what's the exact problem . But you can try below methods :

  1. npx create-react-app my-app( IF you are using node version >=8

  2. Add C:\Users\ugur\AppData\Roaming\npm OR C:\Users\Admin\AppData\Roaming\npm\node_modules to windows PATH variable.

  3. Use this npx create-react-app new_app --use-npm

  4. If you didn't understand the 2nd one solution or maybe path will be different they use below method :

=>Check your global directory by using command npm root -g

=>check the folder, will it have .cmd of your installed packages.

=>If yes, Please copy the path of folder and put in path of user variable

Jagroop
  • 1,777
  • 1
  • 6
  • 20
0

After adding the PATH variable as described above do the following:

On your Desktop, inside the created "myreactapp" folder is where you will find the "node_modules" folder.

I found that deleting that folder as well as the package-lock file did not resolve the issue as each time you run npm install, it will install the latest version of react (18.0.0).

The solution is opening the package.json file which can also be found in your "myreactapp" folder. Edit the version for react and react-dom from 18.0.0 to 17.0.2 as described here https://stackoverflow.com/a/71836018/1250552

save the file after updating the versions and then on your command prompt run "cd myreact app" then npm start

This will open your React app in the browser at localhost 3000

Fruitymo
  • 33
  • 7