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

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

Related

Updating Node.js doesn't seem to work, I still get the old version

I want to run create react app. I run the command:
npx create-react-app client
but I get this error:
You are running Node 10.9.0.
Create React App requires Node 14 or higher.
Please update your version of Node.
I updated it with latest version and using node -v it is showing version v18.13.0. But after that I'm still getting same error.
How do I solve the problem?
Things to try when this sort of thing happens:
If you haven't already, close the command prompt / terminal window where you're running this and open a new one.
If that doesn't work, completely reboot (mostly a Windows thing).
If that doesn't work, completely uninstall Node.js, reboot (mostly a Windows thing), and then install the latest.
Usually if the first two don't solve the problem, the last will.
You can manually define which Node engine to use for your project in package.json file.
{
"name": "client",
"version": "0.1.0",
"private": true,
"engines": {
"node": ">=18"
},
"dependencies": {
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^1.2.2",
"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"
]
}
}
I got answer for this from other site which you can use
npm uninstall -g create-react-app
npm install -g create-react-app#3.4.1
create-react-app my-app --scripts-version 3.1.1

eslint Failed to load config "react-app" to extend from. when making changes in project

I created a react app using yarn create react-app. Then I run yarn start and the project run properly on localhost. However, when I make an edit to a file (add a new tag, rename contents of a div..) the app throws an error and fails to compile with the error
[eslint] Failed to load config "react-app" to extend from.
Eslint is already installed. The crazy thing is, opening the package.json file and saving it solves the issue and the project compiles with the new changes. However I'd have to do this every time I make a change.
I am using Ubuntu on WSL .
Here is my package.json file
{
"name": "gmail-clone",
"version": "0.1.0",
"private": true,
"dependencies": {
"#reduxjs/toolkit": "^1.8.1",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.0.1",
"#testing-library/user-event": "^14.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.0"
},
"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"
]
}
}
A few ways to solve the issues:
Add the eslint-config-react-app
yarn add eslint-config-react-app -D OR yarn add eslint-config-react -D
Remove this code from package.json
"extends": [
"react-app"
]
},
Remove yarn.lock and reinstall node modules.
I had a similar problem, and I resolved it by installing eslint-config-react-app:
yarn add eslint-config-react-app -D

React Js : Failed to Compile

I moved to windows 11 from Linux , so i imported all my code from Linux..to windows .
So whenever i try to run a react project , I get a compile error stating :
Failed to compile
./src/index.js
Module not found: Can't resolve 'react/jsx-dev-runtime' in 'D:\code\react-workspace\react-advanced-2020-master\src'
This error occurred during the build time and cannot be dismissed.
React. js is an open-source JavaScript library that is used for building user interfaces specifically for single-page applications. It's used for handling the view layer for web and mobile apps. React also allows us to create reusable UI components, Had to write something as it was displaying error :)
I tried npm i -g react-scripts and npm clean install
package.json
{
"name": "tutorial",
"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-router-dom": "^5.2.0",
"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"
]
}
}

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\""

i run npx create-react-app and npm start command not working?

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /mnt/c/Users/x/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/mnt/c/Users/x/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/josh/.npm/_logs/2020-08-21T20_00_59_578Z-debug.log
{
"name": "todos-clone-app",
"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",
"webpack-dev-server": "^3.11.0"
},
"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"
]
}
}

Categories

Resources