Errors on 'concurrently "npm run server" "npm run client" with MERN - node.js

First of all, I would like to apologize for the spelling mistakes, I'm not very good.
I have a problem whilethe starting my mern server...
I want to run it with with "npm run dev". This command line execute "npm run server" and "npm run client".
Here's my errors :
C:\Users\Jérémy\Desktop\Rendu\MERN\MERN_d04>npm run dev
mern_d04#1.0.0 dev C:\Users\Jérémy\Desktop\Rendu\MERN\MERN_d04
concurrently "npm run server" "npm run client"
[0] Error occurred when executing command: npm run server
[0] Error: spawn cmd.exe ENOENT
[0] at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[0] at onErrorNT (internal/child_process.js:467:16)
[0] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] Error occurred when executing command: npm run client
[1] Error: spawn cmd.exe ENOENT
[1] at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[1] at onErrorNT (internal/child_process.js:467:16)
[1] at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] npm run client exited with code -4058
[0] npm run server exited with code -4058
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mern_d04#1.0.0 dev: `concurrently "npm run server" "npm run client"`>npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern_d04#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\Jérémy\AppData\Roaming\npm-cache\_logs\2020-04-22T19_45_03_286Z-debug.log
And Here's, my root package.json :
{
"name": "mern_d04",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"client-install": "npm-install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"concurrently": "^5.1.0",
"express": "^4.17.1",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.9.10",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"validator": "^13.0.0"
},
"devDependencies": {
"nodemon": "^2.0.3"
}
}
And here's my client package.json :
{
"name": "client",
"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",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"jwt-decode": "^2.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"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've tried many things and, the most surprising thing is : it works on the computer of my friend but not mines.
Please someone can help me? :)
EDIT : Node version : 13.0.0
EDIT : Found the solution. I "just" had a variable "C:\Windows\System32" in the environment variables :)

I was facing the same problem.
for this code works, you can try this.. on your root package.json
"scripts": {
"start": "node index",
"server": "nodemon index",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"cd client && npm start\""
},
and then from root directory type npm run dev

The node_modules are not compatible with your current systems. You may remove the node_modules folders at the root level AS WELL AS at the client level. Then you install both node_modules AGAIN.

Related

yarn start command failed with exit code 127

Every time I try to start my project as usual using "yarn start" I get the "Command failed with exit code 127" error. I've realised I started to get this error once I've updated my iOS to Monterey v12.6.1 . My node version is not compatible with the yarn it seems like.
What have I tried to fix this:
I have tried to upgrade/update my node version.
I have uninstalled manually node/npm and yarn and reinstall them back with node version 16.0.0
I have deleted the node_modules and package_lock.json
I have had run the command "yarn" and every other update/upgrade command
Everything that I have tried failed.
This is the yarn error log:
Yarn version:
1.22.10
Node version:
15.7.0
Platform:
darwin x64
Trace:
Error: getaddrinfo ENOTFOUND registry.yarnpkg.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:69:26)
npm manifest:
{
"name": "web",
"version": "0.1.0",
"homepage": "https://danibis.github.io/",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"cors": "^2.8.5",
"express": "^4.17.2",
"focus-trap-react": "^8.9.1",
"leaflet": "^1.8.0",
"node-sass": "^6.0.1",
"nodemailer": "^6.7.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-leaflet": "^4.0.0",
"react-scripts": "4.0.3",
"styled-components": "^5.3.3",
"web-vitals": "^1.0.1",
"webpack-hot-middleware": "^2.25.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "yarn run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
]
}
yarn manifest:
No manifest
Lockfile:
No lockfile
Any other idea how to sort this out would be much appreciated.
Thank you for your time!

Build React JS docker image npm install error Could not resolve dependency and Conflicting peer dependency: react#17.0.2

can someone tell me the problem with my Dockerfile , i tried build image react js with docker and somehow it always show error when step run npm install
dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package.json .
COPY package-lock.json .
#COPY . .
#RUN npm install -g npm#8.19.3
#RUN npm install react-scripts
#RUN npm ci
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "run", "start"]
package.json
{
"name": "app-test",
"version": "0.1.0",
"private": true,
"dependencies": {
"#emotion/react": "^11.10.4",
"#emotion/styled": "^11.10.4",
"#fontsource/roboto": "^4.5.8",
"#mui/icons-material": "^5.10.9",
"#mui/material": "^5.10.8",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"blueimp-md5": "^2.19.0",
"file-saver": "^2.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-excel-export": "^1.0.6",
"react-excel-renderer": "^1.1.0",
"react-redux": "^8.0.4",
"react-router-dom": "^6.4.2",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"sass": "^1.55.0",
"web-vitals": "^2.1.4",
"xlsx": "^0.18.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"homepage": ".",
"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"
]
}
}
and i have very very long package-lock.json
i tried to change npm install to npm install -g npm#8.19.3 from npm suggestion, and after i change dockerfile, it success build image, but when i tried to run container, it says
> app-test#0.1.0 start
> react-scripts start
sh: react-scripts: not found
can anyone tell me where am i wrong ?

ReferenceError: loader is not defined

I have been developing a React app with nodejs backend. Now I'm getting this error when I run npm run build. I have update node and npm to latest versions. I'm getting the following error log in the console.
$ npm run build
> client#0.1.0 build C:\Demos\mern-course\client
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/App.css
ReferenceError: loader is not defined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My package.json is as follows.
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.4.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.4.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.2.0",
"react-scripts": "^3.4.0",
"react-transition-group": "^4.3.0",
"reactstrap": "^8.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"uuid": "^3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"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"
]
}
}
Here is the link for github repo for the code.
./src/App.css
ReferenceError: loader is not defined
You need to check that you are importing App.css correctly. This should be in your App.js
Replace "css-loader" folder in front end node-modules folder with another "css-loader" which has taken from working react project.

Nodejs app with Heroku failing on "react-scripts: Permission denied"

I am trying to push my app to Heroku, but I am getting an error when it gets to the heroku postbuild script:
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote: audited 905058 packages in 15.807s
remote: found 0 vulnerabilities
remote:
remote:
remote: > client#0.1.0 build /tmp/build_b7466d5902dcde0a3dc95258046c08c6/client
remote: > react-scripts build
remote:
remote: sh: 1: react-scripts: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! client#0.1.0 build:react-scripts build
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the client#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.CXg0t/_logs/2019-10-17T19_19_39_823Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! safety-influence#1.0.0 heroku-postbuild:NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the safety-influence#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.CXg0t/_logs/2019-10-17T19_19_39_835Z-debug.log
Here is my package.json folder on the server side:
{
"name": "safety-influence",
"version": "1.0.0",
"description": "",
"engines": {
"node": "12.3.1"
},
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "David Jaenike",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"concurrently": "^4.1.2",
"express": "^4.17.1",
"gridfs-stream": "^1.1.1",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.7.3",
"multer": "^1.4.2",
"multer-gridfs-storage": "^3.3.0",
"nodemon": "^1.19.3",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"validator": "^11.1.0"
},
"devDependencies": {
"nodemon": "^1.19.1"
}
}
and on the client side:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"classnames": "^2.2.6",
"file-saver": "^2.0.2",
"jwt-decode": "^2.2.0",
"moment": "^2.24.0",
"react": "^16.10.1",
"react-app-polyfill": "^1.0.4",
"react-dom": "^16.10.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.2.0",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"sweetalert2": "^8.18.0",
"sweetalert2-react-content": "^1.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:80",
"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"
]
},
"devDependencies": {
"react-social-icons": "^4.1.0"
}
}
I have tried running npm install on both the server and client side again, and have also deleted, the reinitialized the git repository. No luck. ANyone have any advice on how to get this build working?

Inside the Node script - npm ERR! code ELIFECYCLE

I have very interesting problem. I have node + react script. Example folders in below;
/client(React is here)
...some react folders + files
...package.json
/models
/routes
/package.json
When i try the create-react-app client in different folder "npm start" works correctly, but when i create react inside the node script npm start command gives error.
npm ERR! code ELIFECYCLE
package.json(node)
{
"name": "nodesrv",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"server": "nodemon server.js",
"dev": "concurrently \"npm run server\" \"cd client && npm start\"",
"start2": "node server.js",
"start": "cd client && npm install && npm run build",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"emailjs": "^2.2.0",
"express": "^4.16.4",
"is-empty": "^1.2.0",
"morgan": "^1.9.1",
"mysql2": "^1.6.5",
"next": "^8.1.0",
"nodemailer": "^6.1.1",
"pg": "^7.11.0",
"pg-hstore": "^2.3.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rotating-file-stream": "^1.4.1",
"sequelize": "^5.8.5",
"validator": "^10.11.0",
"winston": "^3.2.1"
}
}
package.json (react)
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.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"
]
}
}

Resources