npm start not working in create-react-app: missing script:start - reactjs

I tried to update my version of create-react-app by doing this:
If you've previously installed create-react-app globally via npm
install -g create-react-app, we recommend you uninstall the package
using npm uninstall -g create-react-app to ensure that npx always uses
the latest version.
But now, when I run npm start, i get an error message:
missing script: start
But in the package.json from my app, i found the start script:
{
"name": "dropzone-montessori",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.2.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"
]
}
}
Anybody knows what's happening?

Related

npm install does not modify the package.json in react app

I just created React App by "npx create-react-app", and then when I do "npm install redux" or "npm install --save-dev redux" or "npm install --save redux" - it just does not modify the package.json
I tried the same thing with "react-redux", "react-thunk"... And still... The package.json remains the same.
I do not know how to fix this.
Please, help.
"name": "basic_redux_setup",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.8",
"#testing-library/react": "^11.2.3",
"#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"
]
}
}
Make sure you are on the right directory while executing the NPM scripts, which must be the same directory where the package.json file is located.

Can't use createRef in latest version of create-react-app

I am learning React using create-react-app, and I'm getting this error in my app:
TypeError: react__WEBPACK_IMPORTED_MODULE_0___default.a.createRef() is not a function
Now, I know that this feature was only introduced in React 16.3, but that seems to be the version I have installed. I initialized everything by typing:
npx create-react-app probando02
If I check my version:
npm view react version
16.13.1
And my package.json file is:
{
"name": "probando02",
"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"
]
}
}
EDIT: my React environment, as shown by npx create-react-app --info:
Environment Info:
current version of create-react-app: 3.4.1
running from C:\Users\paulo\AppData\Roaming\npm-cache\_npx\21716\node_modules\create-react-app
System:
OS: Windows 10 10.0.18362
CPU: (24) x64 AMD Ryzen Threadripper 1920X 12-Core Processor
Binaries:
Node: 12.16.3 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.14.7 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.18362.449.0
Internet Explorer: 11.0.18362.1
npmPackages:
react: ^16.13.1 => 16.13.1
react-dom: ^16.13.1 => 16.13.1
react-scripts: 3.4.1 => 3.4.1
npmGlobalPackages:
create-react-app: Not Found
So what's going on?
I am using the same version but it works fine for me.
And also here is my package.json file
{
"name": "example",
"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",
"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"
]
}
}
It worked fine for me it was launching the default website in port 3000.
I think its just a update issue or so, just try updating npm.

Why show error [ react-router-dom#5.2.0 requires a peer of react#>=15 but none is installed. You must install peer dependencies yourself.]

I wanna show page on using 'react-router-dom' in react.
And show error
[react-router-dom#5.2.0 requires a peer of react#>=15 but none is
installed. You must install peer dependencies yourself.].
But my react version is "^16.13.1" already.
package.json
{
"name": "pra_hook",
"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",
"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"
]
}
}
I got the same issue. But it got resolved when I use the below command:
npm install react-router-dom
Instead of
npm install -g react-router-dom.
Do [npm install react-router-dom] and work

When start server by using `yarn start` in CRA, server is opend too slow

Using CRA, server is opened after about 2 minutes!
Uninstall create-react-app
Uninstall node(npm), yarn clearly
Install node by using nvm
Install yarn using npm
npx create-react-app test
yarn test
same result...
node version: v12.10.0
yarn version: 1.17.3
npx version: 6.10.3
When yarn start,
Starting the development server...
after about 2 minutes...server open!
Before 2 week, It was so fast!
(+ macOS version: 10.14.2, 2015 early, RAM 8G)
How can I speed up my server opening?
It's CRA package.json
{
"name": "test",
"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"
]
}
}

Why ELIFECYCLE error occurs while running npm start?

I had created a new react project and while running it using npm start it shows me ELIFECYCLE error.
I had tried deleting the package.lock.json and node_modules and removed the dependencies and done a fresh npm install. Eventhough the same error occurs again.
This is my package.json file:
{
"name": "tables",
"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"
]
}
}
C:\Users\Srinithi K\tables
this is my path where the react project called tables is present.
output after running npm start:
This might be due to package-lock.json file. If you had not run eject, it might not have occurred. Installing the latest version of npm would help.
Try these fixes:
Go to your application directory in the command prompt,
rm -rf node-modules
npm install npm#latest -g
npm install
You might consider the following command if the above fix doesn't work.
npm install react-scripts

Resources