NPM error when trying to launch react and nodejs - javascript

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

Related

How can I resolve those errors in Vercel?

Im trying to deploy a website but I always have those errors no matter what hoste I use,
here as u can see :
enter image description here
I tried to understand what means postcss, so after found some stuff about that, I put it on my package.json and installed dependence with npm but nothing change, can someone help please ?
Thank you very much
Edit : Yes I'm sorry, here my package.json :
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3000",
"homepage": ".",
"dependencies": {
"#babel/plugin-syntax-flow": "^7.18.6",
"#fortawesome/fontawesome-free": "^6.2.0",
"#fortawesome/fontawesome-svg-core": "^6.2.0",
"#fortawesome/free-regular-svg-icons": "^6.2.0",
"#fortawesome/free-solid-svg-icons": "^6.2.0",
"#fortawesome/react-fontawesome": "^0.2.0",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^14.4.3",
"css-select": "^5.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"react-router-dom": "^6.4.2",
"react-scripts": "5.0.0",
"react-validation": "^3.0.7",
"uuidv4": "^6.2.13",
"web-vitals": "^3.0.3",
"postcss": "^8.4.17",
"postcss-pseudo-class-any-link": "^7.1.6"
},
"scripts": {
"start": "react-scripts --expose-gc --max_old_space_size=12000 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"
]
},
"devDependencies": {
"postcss": "^8.4.17",
"postcss-pseudo-class-any-link": "^7.1.6",
"sass": "^1.55.0"
}
}
and the log from vercel :
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/postcss-pseudo-className-any-link/-/postcss-pseudo-className-any-link-7.1.6.tgz - Not found
npm ERR! 404
npm ERR! 404 'postcss-pseudo-className-any-link#https://registry.npmjs.org/postcss-pseudo-className-any-link/-/postcss-pseudo-className-any-link-7.1.6.tgz' is not in this registry.
npm ERR! 404 This package name is not valid, because
npm ERR! 404 1. name can no longer contain capital letters
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /vercel/.npm/_logs/2022-10-11T11_12_38_905Z-debug-0.log
Detected `package-lock.json` generated by npm 7+...
Running "npm run build"
> my-app#0.1.0 build
> react-scripts build
sh: react-scripts: command not found
Error: Command "npm run build" exited with 127
There is no package called postcss-pseudo-className-any-link. Please check your package.json file and remove the package.
There is package called postcss-pseudo-class-any-link, maybe try installing that.

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

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

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

Issue with npm start

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)

Error when i go into production with react.js

I have create an app with react.js. I wanted to go into production.
I did
npm run build
serve -s build
I go on localhost:5000
The welcome page works very well, but when i go on localhost:5000/maini have an error
404 | The requested path could not be found
I tried to redo npm run build, but that did not work
What do you propose ?
EDIT
Package.json
{
"name": "name-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^5.10.0",
"node-sass": "^4.11.0",
"p5": "^0.8.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-p5-wrapper": "0.0.4",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"socket.io-client": "^2.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
"main": "index.js",
"devDependencies": {},
"author": "",
"license": "ISC"
}
It looks like the "-s" or "--single" argument/option on the serve package is either not working or no longer working as expected so requests to paths other than "/" are not being rewritten.
Take a look at the following issue for the serve package: https://github.com/zeit/serve/issues/525
In my test setup downgrading serve as suggested in the bug report fixed the issue.
npm uninstall -g serve
npm install -g serve#10.1.1
serve -s build
got same issue today and finally it was caused by the wrong path in which I ran the cmd "serve -s build". we need to ensure the cmd running in one level up to "build" folder, eg: we have "opt/build" path, then server cmd needs to be done in /opt/

Categories

Resources