I'm trying to follow some introductory react courses and I can't run npm start to get create-react-app working. I'm on windows 10. The error I usually get is "npm ERR! missing script: start"
I should mention I'm doing this from the command line, which is my Node.js command prompt
Read through some documentation: https://docs.npmjs.com/creating-a-package-json-file https://www.npmjs.com/package/npm-start-command
Searched stack overflow: Missing Script Start, etc.
Ran npm install npm-start-command --save-dev
Tried downgrading npm to 4.6.1, then upgraded back to the latest
Created several versions of package.json with npm init
I've included "start": and various ideas under the scripts portion of package.json including
"start": "node index.js"
"start": "index.js"
"start": "server.js"
{
"name": "react",
"version": "1.0.0",
"description": "react json ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Julie",
"license": "ISC"
}
The problem is there is no index.js so far because none of the modules I'm creating to learn react have started any code yet. This is the number one step in the courses I'm trying to take on Pluralsight and eggheads.io. Then I should just be able to go to http://localhost:3000/ and see the Start React image.
react-fundamentals with author liam-mclennan on Pluralsight has only these directions to start:
1. npm install -g create-react-app
2. create-react-app click-counter (this is the name of the app)
3. cd click-counter
4. npm start
I have tried putting the package.json both in the create-react-app dir and click-counter (the project folder below it)
Eggheads.io "Start Learning React" has these directions:
1. npm -i create-react-app -g
2. create-react-app react-app
3. cd react-app
4. react-app subl .
5. npm start
I get a slightly different error here:
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'C:\Users\julie\react-app\examples\app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:279:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-app@1.0.0 start: node ./examples/app.js
And the package.json was created automatically:
{
"name": "react-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "3.1.1"
},
"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"
]
}
}