close

[Solved] Yarn run error Command failed with exit code 1

I am trying to run my nodejs project with yarn dev command but every time this command fails with Yarn run error Command failed with exit code 1. And then after trying some solutions my error got solved so I am going to share all solutions here.

How Does Yarn run error Command failed with exit code 1 error occurs?

While I am running my node js project with yarn dev command I am facing the following error.

PS C:\Projects\Popup_prod> yarn dev
yarn run v1.13.0
warning package.json: No license field
error Command failed with exit code 1.

How to solve Yarn run error Command failed with exit code 1 error?

  1. How to solve Yarn run error Command failed with exit code 1 error?

    To solve Yarn run error Command failed with exit code 1 error Just run this simple command to upgrade the yarn package: yarn upgrade && yarn add yarn Now, your yarn package is updated to the latest version. and now you can run your project with yarn dev or yarn start.

  2. Yarn run error Command failed with exit code 1

    To solve the Yarn run error Command failed with exit code 1 error You need to delete your node_modules then delete your yarn cache and then reinstall dependencies and then your error will be solved. First of all, delete your node_modules folder manually or with this command: rm -rf node_modules Now, delete yarn_lock.json file: rm -rf yarn_lock.json then Clear your yarn cache by running this command: yarn cache clean And then, run this command to reinstall all dependencies: yarn install Now You can run yarn dev: yarn start OR yarn dev And now your error must be resolved.

Solution 1: Cache Clear

To solve the Yarn run error Command failed with exit code 1 error You need to delete your node_modules then delete your yarn cache and then reinstall dependencies and then your error will be solved.

First of all, delete your node_modules folder manually or with this command.

rm -rf node_modules

Now, delete yarn_lock.json file.

rm -rf yarn_lock.json

then Clear your yarn cache by running this command.

yarn cache clean

And then, run this command to reinstall all dependencies.

yarn install

Now You can run yarn dev.

yarn start
OR
yarn dev

And now your error must be resolved.

Solution 2: Upgrade yarn

Just run this simple command to upgrade the yarn package.

yarn upgrade && yarn add yarn 

Now, your yarn package is updated to the latest version. and now you can run your project with yarn dev or yarn start.

Solution 3: openssl-legacy-provider

Run this command.

export NODE_OPTIONS=--openssl-legacy-provider

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below on which solution worked for you.

Also, Read

Leave a Comment