Npm start problem while installing react, and how to fix it?

Viewed 5143

After installing node and global create-react-app using 'npm install -g create-react-app' I start creating my first app using 'npx(or npm i tried both) create-react-app appname' and it was successfully created until I start the 'npm start' in 'appname' directory which gave me the following errors.

E:\Sang\React\myapp>npm start

myapp@0.1.0 start E:\Sang\React\myapp react-scripts-start

'react-scripts-start' is not recognized as an internal or external command, operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp@0.1.0 start: react-scripts-start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp@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\Sang Tonsing\AppData\Roaming\npm-cache_logs\2020-09-03T12_06_34_133Z-debug.log

This is my script code inside package.json

{
"name": "myfirstreact",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
  ">0.2%",
  "not dead",
  "not op_mini all"
],
"development": [
  "last 1 chrome version",
  "last 1 firefox version",
  "last 1 safari version"
]
}
}

Kindly please help me solve my problem, I am planning to build my own website using react. Thank You so Much

7 Answers

"scripts":{
"start":"react-scripts-start",
"build":"react-scripts-build",
"test":"react-scripts-test",
"eject":"react-scripts-eject",
}

you have to go to your package.json file and look inside scripts, you should see there start script. if you dont have just add it.

In your package.json file change the start script as:

"scripts": {
   "start": "react-scripts start -o",
   "build": "react-scripts build",
   .
   .
   .

I think it's "start": "react-scripts-start" which is causing problem for you.

You may be missing the react-scripts module. Run npm install react-scripts --save in your project and your package.json should be the way it was initially:

"scripts":{
"start":"react-scripts start",
"build":"react-scripts build",
"test":"react-scripts test",
"eject":"react-scripts eject",
}
nvm install 10.23.0
npm start
npm run build

Brother I think your npm version or nodejs version is outdated You’ll need to have Nodejs >= 14.0.0 and npm >= 5.6 on your machine. Or use windows 8.1 , 10 . Not the windows 7

Simple delete the node_modules folder and run npm install in the appname directory. Let me know if it don't help.

  1. delete node_modules
  2. run npm install
  3. after that run npm start

if above does't work

  1. delete node_modules
  2. delete package-lock.json
  3. run npm install
  4. and then npm start

if above solutions does not fixed your problem, try the following this worked for me:

if you want to start on another port or PORT command not found error then do the following steps:

  1. open package.json file
  2. inside script replace the start command with below "start": "set PORT=3006 && react-scripts start"
Related