Why won't npm start execute? - javascript

I keep getting:
C:\AppData>npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\AppData\Roaming\npm-cache\_logs\2019-02-28T18_08_25_285Z-
debug.log
My package file is as follows:
{
"name": "first",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-scripts": "2.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
"cover 99.5%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
I'm new to npm, and when I first downloaded it, I was able to start it up on my local server no problem.
I wanted to switch my browser up, and in doing so, suddenly npm start is having an issue.
I know there are other questions similar, but none of them alleviate my issue.

As #Arfeo said, just call npm run start.

Where is your package.json located?
If your answer is, for example, c:\AppData\Eugene\react-app
you need to change directory (only once),
cd c:\AppData\Eugene\react-app
then run your npm commands
npm start
npm run build
, etc.

Related

npm start fails after creating a new react project using create-react-app

I'm having some trouble with react-scripts after creating a new react project.
I created/initialised the project using npx create-react-app dashboard.
After going inside the dashboard folder and running npm start (without doing anything else beforehand), I get the following error:
>npm start
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
> dashboard#0.1.0 start
> react-scripts start
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
I have checked the package.json file and it does have react-scripts listed (v5.0.1, full package.json below) and checking the node_modules folder shows a react-scripts folder there and react-scripts files (cmd, ps1 and 1 with no extension) inside the .bin folder too.
I've tried clearing the npm cache (npm cache clean -f), installing things again (deleting package-lock.json and node_modules folder then running npm install) and nothing seems to change.
I've also tried running npm start in command prompt, powershell and powershell as an admin. I've also tried restarting my PC and retrying too without any luck.
Specs:
Edition: Windows 10 Pro
Version: 21H2
OS build: 19044.1766
Experience Windows Feature Experience Pack: 120.2212.4180.0
Node JS version: 16.15.1
npm version: 8.11.0
full package.json:
{
"name": "dashboard",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
If anyone has any ideas on how to fix this, I'd appreciate the help. Let me know if you need/want any more info that might help debug this issue
As suggested in this comment: https://stackoverflow.com/a/68394617/2371266, running npm config set script-shell powershell seems to have worked. I tried deleting the script-shell config afterwards and retrying and got the original error again so I'm assuming it is defaulting to something else and that's making things freak out a bit. I guess I'll just keep it pointed at powershell for now.

NPM error when trying to launch react and nodejs

I have a nodejs and reactjs project. I have writen server and it's working by its own and writen a react SPA and its working too by its own. I uses "concurently" for starting them together but then get these errors:
[0] npm ERR! missing script: servernpm run client
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! C:\Users\1\AppData\Roaming\npm-cache\_logs\2020-12-14T18_43_22_867Z-debug.log
[0] npm run server"npm run client exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shop#1.0.0 dev: `concurrently "npm run server""npm run client"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the shop#1.0.0 dev 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\1\AppData\Roaming\npm-cache\_logs\2020-12-14T18_43_22_906Z-debug.log
I have deleted node_modules in client dir and install it agin but it did help me
Here is my main package.json
{
"name": "shop",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "node app.js",
"server": "nodemon app.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\"\"npm run client\""
},
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.3.3",
"express": "^4.17.1",
"express-validator": "^6.8.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.11.7"
},
"devDependencies": {
"concurrently": "^5.3.0",
"nodemon": "^2.0.6"
}
}
here is my client package.json(react)
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.6",
"#testing-library/react": "^11.2.2",
"#testing-library/user-event": "^12.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Can you help me? I would appriciate that!
Your script is not written correctly, it "glues" lines together and you get this: servernpm run client.
Change it to:
"dev": "concurrently \"npm run server\" \"npm run client\""

npm ERR! missing script: start when trying to run my React app

The error is -
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\mattj\AppData\Roaming\npm-cache\_logs\2020-10-09T07_53_19_254Z-debug.log
yet I've checked my package.json and the "start" script is right there.
{
"name": "gmcb-react",
"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"
]
}
}
I'm new to React, so is there a command I'm supposed to run before npm start? I've tried running npm init first to no avail.
Make sure you're in the right folder before you run a script
You can check what file you're in via the terminal command cwd
If you're no in the right folder make sure you're in the same folder as your package.json

Issue with npm start

I have an issue when using npm start (used create-react-app). Anyone that can see what's wrong?
Error notification in my terminal:
npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\charl\Desktop\IRONHACK\react-interview\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\charl\Desktop\IRONHACK\react-interview\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
{
"name": "particeep",
"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.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"
]
}
}
try to delete package.json and write npm install
npm cache clean -f
rm -rf node_modules
npm i
I think you used npm create-react-app projectname (with npm). This should NOT be done.
You want to use npx create-react-app projectname (with npx) when creating a new project.
I made the same mistake for my first project. Instead of messing around with the terminal, the simplest option I found was just copy the files you already have, delete the folder, and create a new react folder with npx
you have to use npm start after going to the root folder of the app by entering cd your_app_name(app name which used with npx creat-react-app code in terminal)

Error when i go into production with react.js

I have create an app with react.js. I wanted to go into production.
I did
npm run build
serve -s build
I go on localhost:5000
The welcome page works very well, but when i go on localhost:5000/maini have an error
404 | The requested path could not be found
I tried to redo npm run build, but that did not work
What do you propose ?
EDIT
Package.json
{
"name": "name-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^5.10.0",
"node-sass": "^4.11.0",
"p5": "^0.8.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-p5-wrapper": "0.0.4",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"socket.io-client": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
"main": "index.js",
"devDependencies": {},
"author": "",
"license": "ISC"
}
It looks like the "-s" or "--single" argument/option on the serve package is either not working or no longer working as expected so requests to paths other than "/" are not being rewritten.
Take a look at the following issue for the serve package: https://github.com/zeit/serve/issues/525
In my test setup downgrading serve as suggested in the bug report fixed the issue.
npm uninstall -g serve
npm install -g serve#10.1.1
serve -s build
got same issue today and finally it was caused by the wrong path in which I ran the cmd "serve -s build". we need to ensure the cmd running in one level up to "build" folder, eg: we have "opt/build" path, then server cmd needs to be done in /opt/

Categories

Resources