missing script error during the initialization of a react app - node.js

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

Related

Peer dependency issue in React on Travis CI server

When attempting to build an application on a Travis CI server, an error returns stating a peer dependency issue as stated below:
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^15" from react-router-dom#4.1.1
npm ERR! node_modules/react-router-dom
npm ERR! react-router-dom#"^4.1.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#15.7.0
npm ERR! node_modules/react
npm ERR! peer react#"^15" from react-router-dom#4.1.1
npm ERR! node_modules/react-router-dom
npm ERR! react-router-dom#"^4.1.1" from the root project
npm ERR!
I was initially using npm but switched to yarn on the .travis.yml file, to no success.
How do I fix the issue?
Edit: Added package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": {
"/auth/*": {
"target": "http://localhost:5000"
},
"/api/*": {
"target": "http://localhost:5000"
}
},
"dependencies": {
"axios": "^0.16.2",
"materialize-css": "^0.100.2",
"react": "^16.0.0-alpha.13",
"react-dom": "^16.0.0-alpha.13",
"react-redux": "^5.0.5",
"react-router-dom": "^4.1.1",
"react-scripts": "1.0.10",
"redux": "^3.7.1",
"redux-form": "^7.0.1",
"redux-thunk": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
As you can see here, react-router-dom has declared react package as a peerDependencies with a specific version. Meaning react-router-dom expects you to have installed react v15. But you have installed React v16.0.0-alpha.13.
You should downgrade your react package or upgrade your react-router-dom.

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

Npm start problem while installing react, and how to fix it?

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"

Why is npm start error creating react app

I'm learning reactjs
I started with installing nodejs
and then ran these commands inside my project folder "React"
npx create-react-app hello-world
cd hello-world
npm start
but then instead of going to the browser i receive error:
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\abc\AppData\Roaming\npm-cache_logs\2020-02-21T13_34_26_640Z-debug.log
PACKAGE.JSON CODE:
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.4.0"
}
}
Help me solve this error i dont want it to demotivate me from learning React
npm scripts are missing inside your package.json file
npm ERR! missing script: start
Edit your package.json as follows:
{
"name": "hello-world",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build"
},
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.4.0"
}
}
I was also facing almost same type of problem. But then tried
yarn create react-app my-app
in power shell with admin privilege which seemed to do the trick.
Also you’ll need to have Node >= 8.10, yarn >= 0.25+ on your machine
as the official doc suggests.

sh: react-scripts-start: command not found

I have a project that I cannot run npm start on.
I haven't touched this project in two weeks. The only thing I did yesterday was add a git repository, that's it.
When I tried to run npm start I got this error:
sh: react-scripts-start: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! bk-react-replica#0.1.0 start: 'react-scripts-start'
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the bk-react-replica#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I've looked at the solutions on other posts about this same error but none work for me. I've deleted the node_modules directory and package-lock.json files, then ran npm install.
However, I still get the same error message. Does anyone know what's wrong?
This is my package.json file:
{
"name": "bk-react-replica",
"version": "0.1.0",
"private": true,
"homepage": "http://qhafeezdomain.dreamhosters.com/projects/bkreplica",
"dependencies": {
"antd": "^3.3.0",
"normalize.css": "^8.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-native-scripts": "^1.13.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.2.2",
"react-scripts": "^1.1.4",
"react-scripts-cssmodules": "^1.0.171",
"redux": "^3.7.2"
},
"scripts": {
"start": "react-scripts-start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
As I will reference you to an answer I provided to a question similar to yours, run this:
npm i -g npm //which will update npm
rm -rf node_modules/ && npm cache clean // to remove the existing modules and clean the cache.
npm install //to re-install the project dependencies.
Edited:
I just noticed your package.json it should be:
"scripts": {
"start": "react-scripts start",
not
"scripts": {
"start": "react-scripts-start",

Resources