24

I'm trying to run the React server by running npm start

When I do this I get a missing script error:

λ npm start
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aristophanes\AppData\Roaming\npm-cache\_logs\2019-05-15T11_34_47_404Z-debug.log

Full error log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.4.1
3 info using node@v11.1.0
4 verbose stack Error: missing script: start
4 verbose stack     at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
4 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:418:5
4 verbose stack     at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:373:45)
4 verbose stack     at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:416:3)
4 verbose stack     at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack     at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
4 verbose stack     at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack     at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:242:13)
5 verbose cwd C:\Users\Aristophanes\eth-todo-list-react
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
8 verbose node v11.1.0
9 verbose npm  v6.4.1
10 error missing script: start
Aristophanes
  • 475
  • 1
  • 9
  • 21

11 Answers11

22

global installs of create-react-app are no longer supported.

do it:

npm uninstall -g create-react-app

now do it:

npm install create-react-app

now create your app

npx create-react-app yout-app-name

Márcio Soares
  • 371
  • 2
  • 3
10

Installing create-react-app globally is now discouraged. Instead uninstall globally installed create-react-app package by doing: npm uninstall -g create-react-app (may require run as sudo if you get permission related errors or manually delete package folder if this command didn't work for you. Some users have reported they had to delete folders manually)

Then you can run npx create-react-app my-app to create react app again.

npx is available for npm version >= 5.2

ref: https://github.com/facebook/create-react-app/issues/8086

Shinebayar G
  • 4,624
  • 4
  • 18
  • 29
8

Update create-react-app package to solve this problem.

For updating the concerned package run the following command: npm install -g create-react-app

n0noob
  • 889
  • 8
  • 23
5

For windows

tried npm uninstall -g create-react-app that didn't work for me.

I did the following and it worked:

  1. Elevated cmd prompt (or Git Bash): where create-react-app it was somewhere in the system files under yarn. follow that path and delete both the files.
  2. Go to the working directory where you want the project, in my case a folder inside Documents\Projects. run npx create-react-app my-test-app

This will create a new folder called my-test-app and you can follow the rest of the instructions on the react app website.

cd into that new folder, run

yarn start

SAndriy
  • 670
  • 2
  • 15
  • 25
Dhruv
  • 645
  • 9
  • 17
2

Check the names of the scripts in the package.json file, they may be called something different to start. e.g. this part:

"scripts": {
  "build": "cd packages/react-scripts && node bin/react-scripts.js build",
  "start": "cd packages/react-scripts && node bin/react-scripts.js start",
},

Also, try printing your working directory using pwd and check to see if the current directory is correct and run npm run start again.

Robert Anderson
  • 1,246
  • 8
  • 11
  • The only lines in the package.json for the directory I'm working in are: { "name": "eth-todo-list-react", "version": "0.1.0", "private": true } – Aristophanes May 15 '19 at 11:53
  • Create react app creates a package json file in the root of the project. Its possible you are looking at a different package json file? e.g. see the example of what the scripts object should contain here: https://github.com/facebook/create-react-app/blob/master/package.json – Robert Anderson May 15 '19 at 11:55
  • I am now looking at the package.json in the folder "create-react-app". There are no scripts there. I have no idea why. – Aristophanes May 15 '19 at 12:04
  • You may need to install create-react-app again? e.g. npx create-react-app my-app cd my-app npm start – Robert Anderson May 15 '19 at 12:10
  • when i do that it just says "up to date in 0.063s" – Aristophanes May 15 '19 at 12:15
  • what is in package.json now? – Robert Anderson May 15 '19 at 12:17
  • If I install create-react-app again I just get another boatload of errors. The package.json is still exactly the same. Yknow what, forget it. I appreciate your help but this whole thing is just so damn frustrating I can't be bothered with it anymore. Seconds of progress is halted by hours and hours of trying to fix literally endless errors. – Aristophanes May 15 '19 at 12:22
  • OK probably best to start again with a blank slate then with create react app. Good luck. – Robert Anderson May 15 '19 at 12:25
  • You’ll need to have Node >= 6 and npm >= 5.2 on your machine – Robert Anderson May 15 '19 at 12:48
2

This problem has created and still is creating a lot of headaches:

https://github.com/facebook/create-react-app/issues/8308
https://github.com/facebook/create-react-app/issues/8086

Basically the suggestion is correct, may be you have an old version of something around, first try to remove the global create-react-app

npm uninstall -g create-react-app

Then try to update the npm and all the packages.

npm install -g npm@latest

Then you can run to create react app again.

npx create-react-app my-app

This has solved the issue in my case

freedev
  • 25,946
  • 8
  • 108
  • 125
1

Just in case. From the docs:

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

gdfgdfg
  • 3,181
  • 7
  • 37
  • 83
1

I had this problem and managed to fix it by removing the create-react-app with this the npm uninstall -g create-react-app command. This ensured that the npx would always use the latest create-react-app version.

Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
ali
  • 11
  • 6
0

For me the problem was caused because npx create-react-app my-app was not triggering npm install due to lack of user permission. Please run :

sudo npx create-react-app my-app

Solves the problem.

Anurag Kumar
  • 1,355
  • 11
  • 11
0

I found that my problem was extremely simple:

I had opened the parent folder of my React project, instead of the child folder that contains /src and /public.

Once I opened this folder, the script started running fine.

Lathryx
  • 428
  • 1
  • 4
  • 15
0

In my case I uninstalled everything and reinstalled it

npm uninstall -g create-react-app

npm install create-react-app

npx create-react-app yout-app-name

And later install MUI library (in my case :D)

npm install @mui/material @emotion/react @emotion/styled
m4n0
  • 29,823
  • 27
  • 76
  • 89