After cloning a Git repo with a ReactJS and NodeJS project and install NodeJS
wanted to see the result in the browser and for that had to run in the root folder which had a package.json
npm install
and after
npm start
First command worked fine but the second was giving the following error
> HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start
'HOST' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ...: `HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ... 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:
The package.json has the following
"scripts": {
"start": "HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start",
Tested using Git Bash, CMD and PowerShell and kept on getting the same error, as you can see in the following images
Git Bash
CMD
PowerShell
If I run (without using the npm wrapper script)
HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start
it works fine. As Quentin says,
Must be something to do with how npm shells out then
To fix it, I've gone to package.json and changed the "start" script to
"start": "./node_modules/.bin/react-scripts start",
Then npm start
works fine.
Use the cross-env package.
For that install it using the following command
npm i cross-env
then go to package.json and change it to
"start": "cross-env ./node_modules/.bin/react-scripts start",
And then running npm start
will also work fine:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With