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)
Related
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 install is failing with the below message. I tried deleting the node_modules folder and installing it again, but it didn't work:
15104 error command sh -c node-gyp-build
15105 error sh: node-gyp-build: command not found
How can I solve this?
Error log of npm install --verbose:
npm ERR! code 127
npm ERR! path /Users/johnnycheng/Documents/React Projects/blockchain:fintech/coin-web-test2/node_modules/utf-8-validate
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! sh: node-gyp-build: command not found
npm verb exit 127
npm timing npm Completed in 30755ms
npm verb unfinished npm timer reify 1650620386080
npm verb unfinished npm timer reify:build 1650620407577
npm verb unfinished npm timer build 1650620407582
npm verb unfinished npm timer build:deps 1650620407583
npm verb unfinished npm timer build:run:install 1650620407669
npm verb unfinished npm timer build:run:install:node_modules/bufferutil 1650620407670
npm verb unfinished npm timer build:run:install:node_modules/utf-8-validate 1650620407692
npm verb code 127
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/johnnycheng/.npm/_logs/2022-04-22T09_39_45_773Z-debug-0.log
File package.json of my project:
{
"name": "coin-web-test2",
"version": "0.1.0",
"private": true,
"dependencies": {
"#emotion/react": "^11.9.0",
"#emotion/styled": "^11.8.1",
"#fontsource/roboto": "^4.5.5",
"#mui/material": "^5.6.2",
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "^13.0.0",
"#testing-library/user-event": "^13.2.1",
"crypto-js": "^3.1.9-1",
"ethers": "^5.6.4",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.3.0",
"react-scripts": "4.0.3",
"web-vitals": "^2.1.0",
"web3": "^1.7.3"
},
"scripts": {
"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js 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"
]
}
}
Check the full error log here: Full error log
Environment: macOS v12.3.1 (Monterey)
Node.js version: 16.14.2
npm version: 8.7.0
Running yarn install and then npm install somehow works.
I don't any idea how.
Try installing using this command as follows:
npm install node-gyp
I can't find node-gyp module in your package.json file.
Try running npm install node-gyp and following the instructions for node-gyp module npm link.
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"
]
}
}
I'm new to using npm and node I created a react app with truffle unbox react which uses npm init react-app. I have tried reinstalling npm and clearing the cache but I keep getting the following error when I run sudo npm start.
npm ERR! code EJSONPARSE
npm ERR! file /home/a/Documents/so/client/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token { in JSON at position 634 while parsing near '...rsion"
npm ERR! JSON.parse ]
npm ERR! JSON.parse }
npm ERR! JSON.parse }
npm ERR! JSON.parse
npm ERR! JSON.parse {
npm ERR! JSON.parse "name": "mapboxAnd...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/a/.npm/_logs/2020-06-21T17_39_45_819Z-debug.log
My package.json looks like this.
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "16.11.0",
"react-dom": "16.11.0",
"react-scripts": "3.2.0",
"web3": "1.2.2"
},
"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"
]
}
}
As far as I can tell package.json is nothing but json. Please help me understand this error. Thankyou.
Your package.json is a valid JSON file, the error is somewhere else.
Can you please do the below:
run the package without sudo, e.g. "npm start" instead of "sudo npm start", you shouldn't run your packages as root.
have a look at the log file "/home/a/.npm/_logs/2020-06-21T17_39_45_819Z-debug.log" and post more details.
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.