I am trying to create a react project i have run npx create-react-app my-app then cd my-app but when I've npm start
this error has been shown:
> my-app#0.1.0 start C:\Users\USER\my-app
> react-scripts start
i 「wds」: Project is running at http://192.168.137.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\HAMOOD\my-app\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn powershell ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn powershell',
path: 'powershell',
spawnargs: [
'-NoProfile',
'-NonInteractive',
'–ExecutionPolicy',
'Bypass',
'-EncodedCommand',
'UwB0AGEAcgB0ACAAIgBgACIAaAB0AHQAcAA6AC8ALwBsAG8AYwBhAGwAaABvAHMAdAA6ADMAMAAwADAAYAAiACIA'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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\HAMOOD\AppData\Roaming\npm-cache\_logs\2020-08-23T13_09_04_330Z-debug.log
i have tried to to delete the node_modules then I've installed it another time but the same issue still happening
I've found some possible solutions. Seems that you are using powershell, check firstly that you have it in your PATH as %SystemRoot%/system32/WindowsPowerShell/v1.0. After that open powershell as admin and write
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
It should help in case there is problem with powershell. OR, sometimes it could be an error while cra dev server is trying to open web browser. Someone on github said that this helped him:
This error stems from the fact that CRA tries to open your browser:
In order to skip opening the browser, add
BROWSER=none
to your .env or .env.local file
Another way is to downgrade react scripts for project with these commands
npm install react-scripts#2.1.8
npm start
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.
1- First you need to edit system environment variable and locate where you have Windows Poweshell so add new in "system environment variable path"
2- Then Open Window PoweShell as An Administraror And Write these Two Commands :
:) Upgrade Window PowerShell because your nodejs and npm is updated but powershell is not updated so its making conflict with your npm start or expo start,so you should need to upgrade windows powershell
And Then run Cmd and also run your poject npm start or expo start so quickly it will work!
BEST OF LUCK!
Related
I am developing react app in my localhost and try to deploy the code into github page.
But while running the command npm run deploy its shows below error.
PS D:\Projects\portfolio-app> npm run deploy
> portfolio-app#0.1.0 predeploy D:\Projects\portfolio-app
> npm run build
> portfolio-app#0.1.0 build D:\Projects\portfolio-app
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
41.69 KB build\static\js\2.b0b79569.chunk.js
2.35 KB build\static\js\main.2ad86f1d.chunk.js
1.4 KB build\static\js\3.dc241c04.chunk.js
1.17 KB build\static\js\runtime-main.b7252dff.js
546 B build\static\css\main.ab7136cd.chunk.css
The project was built assuming it is hosted at /me/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
Find out more about deployment here:
https://cra.link/deployment
> portfolio-app#0.1.0 deploy D:\Projects\portfolio-app
> gh-pages -b master -d build
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn git',
path: 'git',
spawnargs: [ 'config', 'user.name' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! portfolio-app#0.1.0 deploy: `gh-pages -b master -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the portfolio-app#0.1.0 deploy 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\AppData\Roaming\npm-cache\_logs\2021-01-04T14_20_16_803Z-debug.log
PS D:\Projects\portfolio-app>
ENOENT means that a file does not exist. The path indicated is git. gh-pages is trying to use git but it seems that it can't find it. Make sure git is in your PATH or that the path is correctly specified in your code.
If that doesn't solve the problem, you might get additional debugging information by prepending NODE_DEBUG=gh-pages to your npm run command.
You need to use the command npm run deploy on the gitbash.
error from cmd
I am trying to install react for the first time but I always get an error whenever I run "npm start" or "yarn start"
C:\react\reactjs>npm install -g yarn
C:\Users\UNCLE BIGBAY\AppData\Roaming\npm\yarnpkg -> C:\Users\UNCLE BIGBAY\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
C:\Users\UNCLE BIGBAY\AppData\Roaming\npm\yarn -> C:\Users\UNCLE BIGBAY\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
+ yarn#1.22.4
updated 1 package in 2.163s
C:\react\reactjs>npm start
> reactjs#0.1.0 start C:\react\reactjs
> react-scripts start
Starting the development server...
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)[39m
[90m at onErrorNT (internal/child_process.js:469:16)[39m
[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)[39m
Emitted 'error' event on ChildProcess instance at:
[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)[39m
[90m at onErrorNT (internal/child_process.js:469:16)[39m
[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)[39m {
errno: [32m'ENOENT'[39m,
code: [32m'ENOENT'[39m,
syscall: [32m'spawn cmd'[39m,
path: [32m'cmd'[39m,
spawnargs: [ [32m'/s'[39m, [32m'/c'[39m, [32m'start'[39m, [32m'""'[39m, [32m'/b'[39m, [32m'"http://localhost:3000"'[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs#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\UNCLE BIGBAY\AppData\Roaming\npm-cache\_logs\2020-04-23T00_06_27_219Z-debug.log
C:\react\reactjs>
I have tried updating the yarn and even reinstalling it
You could downgrade with help of this script and writing that on your terminal then everything should be work:
create-react-app my-app
cd my-app
npm install react-scripts#2.1.8
npm start
This would definitely work. Thanks ))
I had your same problem. I deleted the node_modules folder and reinstalled using:
npm install
After that all works fine.
I find the solution here https://gitmemory.com/issue/facebook/create-react-app/6985/491604318
Please Try After Adding C:\Windows\System32 To Environment Variable Path And Restarting Your Device .
I'm guessing that you are trying to use the create-react-app
did you use npx to set it up?
npx create-react-app joakims-app
cd joakims-app
npm start
BTW: It looks like you are running windows - don't know if this is of any help
https://makandracards.com/reactjs-quick/52419-install-reactjs-windows
I created a new react app using CRA. As soon as I started the development server, it throws the error and exits.
Starting the development server...
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cart-redux#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cart-redux#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logg
ing output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache\_logs\2019-05-26T09_32_50_014Z
-debug.log
The react-scripts version 3.0.1 is avoiding to 'npm start'. I tried downgrading to version 2.1.8, it works fine. But I don't want to downgrade the version everytime to make my app work.
I tried following the similar case, but it didn't help.
Any one else facing the issue, please help to resolve it.
if you tried this and it didn't work for you then this maybe a react-scripts issue so to fix it try this:
remove node_modules and lock files
edit package.json so the version of react-scripts is "2.1.8"
npm install
npm start
LTK how that goes
I tried to deploy my react project on github-pages with npm run deploy and I get the following errors:
events.js:167
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
at onErrorNT (internal/child_process.js:407:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! songs#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the songs#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I've already used npm cache clean, deleted node modules and package-lock.json and ran npm install again. I'm new to React and to programming in general so I can not really figure out what the problem is. Also, I should mention that I am a Windows user. Any help would be much appreciated.
The solution was to set the environment variable $PATH. I followed the steps mentioned here: How do I debug “Error: spawn ENOENT” on node.js?
I've never user gh-pages before so I'm pretty confused on how it works. I followed this guide over on the create react app page for how to deploy your app to git hub, however every time I try I get an error:
> gh-pages -d build
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myApp_game#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myApp_game#0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I have no idea what this means or how to fix it.
If anyone has a similar problem its because git is not added to your PATH. I was running npm run deploy from command prompt in windows, when I ran it in the git shell it worked perfectly.