Npm start problem while installing react, and how to fix it? - node.js

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

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

delete node_modules
run npm install
after that run npm start
if above does't work
delete node_modules
delete package-lock.json
run npm install
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:
open package.json file
inside script replace the start command with below "start": "set PORT=3006 && react-scripts start"

Related

Cannot start React app due to missing script 'start'

I'm newbie to react js.Trying to run a simple app and getting this error and can't figure out what's wrong
D:\React app\react-app1>npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR! npm star # Mark your favorite packages
npm ERR! npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Muralidharan\AppData\Local\npm-cache\_logs\2022-05-29T08_51_37_315Z-debug-0.log
This is package.json file
{
"name": "react-app1",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1"
}
}
Anything wrong with installation? or outdated version something like that?
This happens becaue you have no script called "start" in your package.json file. Here is an example of a package.json file with such script:
{
"name": "your-project",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "node main.js"
},
"author": "Muralidharan",
"dependencies": {
}
}
add this to your package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
},
start is the command you need that trigger react-script to run your project
build, test and eject are other command you will need for development process

missing script error during the initialization of a react app

node ./postinstall.js
react-scripts#4.0.3
react#17.0.2
react-dom#17.0.2
added 1922 packages from 732 contributors and audited 1925 packages in 1282.186s
135 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.
You can fix this by running npm uninstall -g create-react-app or yarn global remove create-react-app before using create-react-app again.
C:\Windows\System32\react-app> npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ObiTech ict Solution\AppData\Roaming\npm-cache_logs\2021-04-05T21_07_44_609Z-debug.log
I got the error above while trying to initiate a new React App
My package.json was missing the start script
The content of the package.json file looks like:
{
"name": "reactapp",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3"
}
}

npm not recongnizing my virtual environment

Im making a react app with flask as backend and im following this article guide, so in this article he adds a custom npm script to start flask app. I did the exact same thing and did npm run start-api but im getting the following error -
> weather-app#0.1.0 start-api C:\Users\Kakshipth\Documents\coding\webdev\weather-app
> cd api && venv/bin/flask run --no-debugger
'venv' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! weather-app#0.1.0 start-api: `cd api && venv/bin/flask run --no-debugger`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weather-app#0.1.0 start-api 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\Kakshipth\AppData\Roaming\npm-cache\_logs\2020-10-31T05_01_09_393Z-debug.log
Yes, i double checked if the name of my virtual environment is correct, and it is correct.
here is my package.json file where i specified the script -
{
"name": "weather-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",
"materialize-css": "^1.0.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-scripts": "3.4.3",
"venv": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"start-api": "cd api && venv/bin/flask run --no-debugger",
"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"
],
"proxy": "http://localhost:5000"
}
}
Any help is appreciated, thanks
in order to run within virtual environment, you need to activate the virtual environment first.
try executing the npm script after you activated the virtual environment
$ source venv/bin/activate
$ npm run start-api
You are running on windows, it doesn't recognize the path you have given in the package.json file, edit the "scripts" as:
"start-api": "cd api && venv\\bin\\flask run --no-debugger",
Then try activating the virutal environment and running npm script.
$ source venv/bin/activate
$ npm run start-api
I also followed the same example and the answer is here: Integration of React framework and Flask framework
You need to run both commands concurrently.
I installed concurrently with yarn then updated the command in the package.json to use both commands according to the concurrently docs, eg.
"start": "concurrently \"command1 arg\" \"command2 arg\""

Getting Error While starting lite-server in npm

i did a fresh "npm init". put entry point : "index.html"
then installed lite-server : npm install lite-server --save-dev
also updated the package.json and I Uninstalled, reinstalled tried everything but it's not working and
also tried npm cache clean --force but it's not working. can any one help with this error.
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run lite",
"lite": "lite-server"
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}
But when I did "npm start" , getting this error
git-test#1.0.0 start D:\Coursera\git-test
> npm run lite
'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! git-test#1.0.0 start: `npm run lite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the git-test#1.0.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\sai\AppData\Roaming\npm-cache\_logs\2020-06-05T10_20_11_723Z-debug.log
I was too facing the same issue after a system shutdown, hence this worked for me:
First uninstall the current local lite-server in node_modules
npm uninstall lite-server
Install lite-server globally and try running the same command
npm install -g lite-server
then hit:
npm start
This fixed the issue for me, thank you
Here's my Json file script if you want to have a look
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
You don't seem to have node/npm installed and configured properly (PATH issues).
I would suggest you try to re-install Node.js using the official instructions for your platform (https://nodejs.org/en/download/) or by using a Node.js version manager like nvm (https://github.com/nvm-sh/nvm) or n (https://github.com/tj/n).
Using nvm or n, will allow you to dynamically switch Node.js version without having to re-install everything from scratch.
Just install the live-server globally,i think that should solve the issue.
sudo npm install --global lite-server
And in your package.json file you can change a little bit.
{
"name": "git-test",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "lite-server",
},
"author": "Sateesh",
"license": "ISC",
"dependencies": {
"lite-server": "^2.5.4"
}
}
After this run this on terminal
npm start
I think this should help :)
I had a similar issue,yarn start worked for

Problem in the command "npm start" Failed at the fourth-tic-tac-toe#0.1.0 start script. npm ERR! react-scripts: not found

I am making a basic tic tac toe game in react. first I create the app with these command's
npx create-react-app my-app
cd my-app
npm start
In the beginning it's working is fine but when I installed some dependencies and again start the app with the command npm start,
give me error
shivam#shivam:~/Documents/Projects/React/fourth-tic-tac-toe$ npm start
> fourth-tic-tac-toe#0.1.0 start /home/shivam/Documents/Projects/React/fourth-tic-tac-toe
> react-scripts start
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! fourth-tic-tac-toe#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fourth-tic-tac-toe#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! /home/shivam/.npm/_logs/2020-04-25T10_03_35_243Z-debug.log
My package.json file is here
{
"name": "fourth-tic-tac-toe",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"bootstrap": "^4.4.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^3.10.0",
"react-scripts": "3.4.1",
"react-toastify": "^5.5.0",
"reactstrap": "^8.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"
]
}
}
and npm version 5.6.0
I installed all the with the command npm install dependency-name
and only one dependency with npm install --save bootstrap
After this installation when I tried to start app give me error
install new version of node
npm install -g npm#latest
Go in your app directory and use this command
npm install react-scripts#2.1.8
It has worked for me.

Resources