Create React App and Git Hub pages - reactjs

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.

Related

can't run "npm run deploy" throw er; //unhandled 'error' event while deploying the react app into Github

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.

React.JS npm start error after successful installation of all packages using create-react-app

I have followed bellow steps for reactjs environment setup.
Installed Node.js with version - v10.16.3
npm version - 6.14.5
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start.
But when I start it using npm start. It is giving me error like events.js:174 throw er; // Unhandled 'error' event
Below is the error stack trace:
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! react-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-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\Prashant Kamble\AppData\Roaming\npm-cache\_logs\2020-06-26T13_39_25_395Z-debug.log
Try to navigate to your project folder and type this commands. It helps me.
rm -rf node_modules
rm package-lock.json
rm yarn.lock
npm cache clear --force
npm install
It was giving issue for react-script version >= 3.0.0
I am able to find solution for this with my one of colleague Shivani i.e we downgraded the version of react-script from 3.4.0 to 2.1.8 by using below command nothing else changed.
Command needs to be executed from project folder or our app so that it can update package.json
https://www.npmjs.com/package/react-scripts/v/2.1.8
npm i react-scripts#2.1.8

React app does not start server with npm start

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

events.js:173 throw er; // Unhandled 'error' event

I am not able to execute "npm start" command. I am getting this error while running this command.
node -v : v12.0.0
npm -v : 6.9.0
I have tried to reinstall all the software.
even I have also changed the port number and try to execute the code.
what should I do?
events.js:173
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.exit (internal/child_process.js:248:19)
at onErrorNT (internal/child_process.js:431:16)
at processTicksAndRejections (internal/process/task_queues.js:83:17)
Emitted 'error' event at:
at Process.ChildProcess._handle.exit (internal/child_process.js:254:12)
at onErrorNT (internal/child_process.js:431:16)
at processTicksAndRejections (internal/process/task_queues.js:83:17)
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\Dhruvi\AppData\Roaming\npm-cache\_logs\2019-04-30T01_57_22_780Z-debug.log
Just delete the node_modules folder, and reinstall npm modules.
npm install
Make sure all the global & local packages that are being used in the scripts are installed, in your case it could be webpack-cli & yarn wasn't installed globally & you are trying to access it using your script.
All Export & PATH environments are setup correctly
rm -rf node_modules && npm install

Can not run 'npm run build' / 'npm run deploy' command in my react app

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?

Resources