Reputation: 11
How to solve this error?
PS G:\ReactJs\ReactApplicationRedux\ReactApplicationRedux> start npm
PS G:\ReactJs\ReactApplicationRedux\ReactApplicationRedux> npm start
> [email protected] start G:\ReactJs\ReactApplicationRedux\ReactApplicationRedux
> PORT=3006 react-scripts start
'PORT' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `PORT=3006 react-scripts start`
npm ERR! Exit status 1
npm ERR! Failed at the [email protected] 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\Manjunathan S\AppData\Roaming\npm-cache\_logs\2021-09-28T17_00_34_422Z-debug.log
PS G:\ReactJs\ReactApplicationRedux\ReactApplicationRedux> mpm start
mpm : The term 'mpm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
+ mpm start
+ ~~~
+ CategoryInfo : ObjectNotFound: (mpm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS G:\ReactJs\ReactApplicationRedux\ReactApplicationRedux> npm start
> [email protected] start G:\ReactJs\ReactApplicationRedux\ReactApplicationRedux
> PORT=3006 react-scripts start
'PORT' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `PORT=3006 react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\Manjunathan S\AppData\Roaming\npm-cache\_logs\2021-09-28T17_00_54_168Z-debug.log
Upvotes: 1
Views: 92
Reputation: 4376
In your package.json you need to make sure
Change
"start": "react-scripts start"
to
Linux:
"start": "PORT=3006 react-scripts start"
or
"start": "export PORT=3006 react-scripts start"
Windows:
"start": "set PORT=3006 && react-scripts start"
Also the best way in my opinion and the one I use is to create a file called
.env.development
at the same level of your package.json
and add
PORT=3006
to your file.
Notice that you can create different .env files like .env.production etc... or simply .env
Environment Variables using .env file in REACT
Upvotes: 1