Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error Command failed with exit code 1. when I try to run yarn

Tags:

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 https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run 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 https://yarnpkg.com/en/docs/cli/run 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}`))
like image 332
hwiba Avatar asked Mar 24 '19 12:03

hwiba


People also ask

What is error command failed with exit code 1?

Exit Code 1 means that a container terminated, typically due to an application error or an invalid reference. An application error is a programming error in any code running within the container.

What is yarn Run command?

The yarn run command is used to run a script that you defined in the script section of your package. json file. Here is an example of a script section in a package.json file: yarn run [script] [<args>]

Can NPM run yarn?

Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.


2 Answers

what you need to do is just simple: follow these steps:

  1. rm -rf node_modules
  2. yarn cache clean
  3. yarn
  4. yarn start
like image 126
Shailesh kala Avatar answered Sep 18 '22 22:09

Shailesh kala


I faced same error and I fixed it by following these steps:

  1. Delete yarn_lock.json or rm -rf yarn_lock.json (if you are Linux/MacOS user)
  2. Delete node_modules/ or rm -rf node_modules/ (if you are Linux/MacOS user)
  3. Follow the instructions to install the latest Yarn package available from here
  4. Try executing following commands in your project root folder:

yarn install and yarn start

In case if the above approach didn't help:

  1. Try to install latest node.js
  2. Remove node_modules/ and lock file
  3. use npm install and npm run-script
like image 20
Karthikaeyan Avatar answered Sep 19 '22 22:09

Karthikaeyan