I am learning reactjs - nodejs I was trying to run the server so I installed yarn, nodemon, express but when I try to run its saying error Command failed with exit code 1.
my error is
PS D:\react project\ReactManagement-tutorial> yarn dev yarn run v1.13.0 warning package.json: No license field $ concurrently --kill-others-on-fail "yarn server" "yarn client" warning package.json: No license field warning package.json: No license field $ nodemon server.js $ cd client && yarn start warning ..\package.json: No license field $ react-scripts start [1] 'react-scripts'��(��) ���� �Ǵ� �ܺ� ����, ��� ��� �� �ִ� ���α�, �Ǵ� [1] ��ġ ������ �ƴմϴ�. info Visit for documentation about this command. error Command failed with exit code 1. info Visit for documentation about this command. error Command failed with exit code 1. [1] yarn client exited with code 1 --> Sending SIGTERM to other processes.. [0] yarn server exited with code 1 error Command failed with exit code 1. info Visit for documentation about this command. PS D:\react project\ReactManagement-tutorial> my package.json is
{ "name": "management", "version": "1.0.0", "scripts": { "client": "cd client && yarn start", "server": "nodemon server.js", "dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"" }, "dependencies": { "body-parser": "^1.18.3", "express": "^4.16.4", "nodemon": "^1.18.10" }, "devDependencies": { "concurrently": "^4.1.0" } } and its my server.js
const express = require('express'); const bodyParser = require('body-parser'); //서버모듈을위한 const app = express(); const port = process.env.PORT || 5000; app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended:true})); app.get('/api/hello',(req,res) =>{ res.send({message : 'hello express!'}); }); app.listen(port,()=>console.log(`listening on port ${port}`)) 19 Answers
what you need to do is just simple: follow these steps:
- rm -rf node_modules
- yarn cache clean
- yarn
- yarn start
I faced same error and I fixed it by following these steps:
- Delete
yarn_lock.jsonorrm -rf yarn_lock.json(if you are Linux/MacOS user) - Delete
node_modules/orrm -rf node_modules/(if you are Linux/MacOS user) - Follow the instructions to install the latest Yarn package available from here
- Try executing following commands in your project root folder:
yarn installandyarn start
In case if the above approach didn't help:
- Try to install latest node.js
- Remove
node_modules/andlockfile - use
npm installandnpm run-script
This should work:
yarn add yarn 0To fix the dependency tree, try following the steps below in the exact order:
- Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
- Delete node_modules in your project folder.
- Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
- Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try:
If you used npm, install yarn () and repeat the above steps with it instead. This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if C:\Users\nouss\OneDrive\Images\SocialM\react-social\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.Try running npm ls webpack in your project folder. This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permble this preflight check in case you want to proceed anyway.
One of the issue that you may face is the server won't start if some other server is running too . For eg. I had XAMP Running and thus my yarn couldn't start itself. Check it once.
This worked for me, (update yarn)
$ yarn info $ yarn upgrade $ yarn add yarn if it shows more errors run this:
export NODE_OPTIONS=--openssl-legacy-provider Done
0Updated the cache and all dependencies (yarn, node, npm), deleted the lock file - nothing helped. The issue was resolved simply by cloning the project to another directory. Apparently some kind of cache is tied to the directory and interferes with the build.
Reinstall yarn and run the function again. This worked for me.
Try this:
1.Reinstall node.js
2.Reinstall VSC (if you use that)
3.Go to cmd and run:
npx create-react-app app-namecd app-nameyarn start
4.Open your app at
5.Close cmd
6.Open VSC and run same command:
yarn start
and app is working! I hope that my solution will help someone.