'i am having trouble installing create-react-app
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'
]
}```
Solution 1:[1]
Delete the whole folder including node_modules.
Run npm install again.
Good luck.
Solution 2:[2]
As the information provided, i didn't get the idea like what's the exact problem . But you can try below methods :
npx create-react-app my-app( IF you are using node version >=8Add
C:\Users\ugur\AppData\Roaming\npmORC:\Users\Admin\AppData\Roaming\npm\node_modulesto windows PATH variable.Use this
npx create-react-app new_app --use-npmIf 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
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SunAider |
| Solution 2 | Jagroop |
| Solution 3 | Fruitymo |
