Issue: bash: yarn: command not found

I’m facing a build issue with my website.

Everything is worked before 2 Dec 2022. I’m not sure that Netlify has new updated version after 2 Dec 2022.

My error

5:06:56 PM: ────────────────────────────────────────────────────────────────
5:06:56 PM:   1. Build command from Netlify app                             
5:06:56 PM: ────────────────────────────────────────────────────────────────
5:06:56 PM: ​
5:06:56 PM: $ CI= yarn build:staging
5:06:56 PM: bash: yarn: command not found
5:06:56 PM: ​
5:06:56 PM: ────────────────────────────────────────────────────────────────
5:06:56 PM:   "build.command" failed                                        
5:06:56 PM: ────────────────────────────────────────────────────────────────
5:06:56 PM: ​
5:06:56 PM:   Error message
5:06:56 PM:   Command failed with exit code 127: CI= yarn build:staging (https://ntl.fyi/exit-code-127)
5:06:56 PM: ​
5:06:56 PM:   Error location
5:06:56 PM:   In Build command from Netlify app:
5:06:56 PM:   CI= yarn build:staging
5:06:56 PM: ​
5:06:56 PM:   Resolved config
5:06:56 PM:   build:
5:06:56 PM:     command: CI= yarn build:staging
5:06:56 PM:     commandOrigin: ui
5:06:56 PM:     environment:
5:06:56 PM:       - NETLIFY_USE_YARN
5:06:56 PM:       - NODE_VERSION
5:06:56 PM:       - YARN_VERSION
5:06:56 PM:     publish: /opt/build/repo/dist/apps
5:06:56 PM:     publishOrigin: ui

My package.json

{
    "name": "app",
    "version": "0.0.0",
    "license": "MIT",
    "engines": {
        "node": ^14.0.0
    },
    "scripts": {
        "ng": "nx",
        "postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main",
        "nx": "nx",
        "start": "ng serve",
        "build:staging": "nx build app -c staging",
    },
    "private": true,
    "dependencies": {
        "@agm/core": "^3.0.0-beta.0",
        "@angular/animations": "12.0.0",
        "@angular/cdk": "12.0.3",
        "@angular/common": "12.0.0",
        "@angular/compiler": "12.0.0",
        "@angular/core": "12.0.0",
        "@angular/fire": "6.1.5",
        "@angular/forms": "12.0.0",
        "@angular/material": "12.0.3",
        "@angular/platform-browser": "12.0.0",
        "@angular/platform-browser-dynamic": "12.0.0",
        "@angular/router": "12.0.0",
        "@circlon/angular-tree-component": "^11.0.4",
        "@fast-csv/format": "^4.3.5",
        "@fast-csv/parse": "^4.3.6",
        "@google-cloud/storage": "^5.8.5",
        "@googlemaps/google-maps-services-js": "^3.1.16",
        "@nestjs/axios": "^0.0.1",
        "@nestjs/bull": "^0.6.1",
        "@nestjs/common": "^7.0.0",
        "@nestjs/config": "^0.6.3",
        "@nestjs/core": "^7.0.0",
        "@nestjs/jwt": "^8.0.0",
        "@nestjs/mongoose": "^7.2.4",
        "@nestjs/platform-express": "^7.0.0",
        "@nestjs/platform-socket.io": "^8.0.6",
        "@nestjs/schedule": "^1.0.2",
        "@nestjs/swagger": "^4.8.0",
        "@nestjs/websockets": "^8.0.6",
        "@ng-bootstrap/ng-bootstrap": "10.0.0",
        "@ngrx/effects": "^12.0.0",
        "@ngrx/entity": "^12.0.0",
        "@ngrx/store": "^12.0.0",
        "@ngrx/store-devtools": "^12.0.0",
        "@ngx-translate/core": "^13.0.0",
        "@ngx-translate/http-loader": "^6.0.0",
        "@nrwl/angular": "12.3.4",
        "@sendgrid/client": "^7.4.3",
        "@sendgrid/helpers": "^7.4.3",
        "@sendgrid/mail": "^7.4.5",
        "@types/multer": "^1.4.7",
        "angular-bootstrap-datetimepicker": "^4.0.2",
        "angular-email-editor": "^0.9.0",
        "angular2-text-mask": "^9.0.0",
        "archiver": "^5.3.0",
        "axios": "^0.24.0",
        "bcryptjs": "^2.4.3",
        "bootstrap": "4.6.0",
        "bull": "^4.10.0",
        "canvas": "^2.9.3",
        "class-transformer": "^0.4.0",
        "class-validator": "^0.13.1",
        "continuation-local-storage": "^3.2.1",
        "convert-csv-to-json": "^1.3.3",
        "express-handlebars": "^5.3.2",
        "express-session": "^1.17.2",
        "fast-csv": "^4.3.6",
        "file-saver": "^2.0.5",
        "firebase": "^7.0 || ^8.0",
        "handlebars": "^4.7.7",
        "html-to-pdfmake": "^2.3.10",
        "ionicons": "4.6.3",
        "jquery": "^3.6.0",
        "jsdom": "19.0.0",
        "json2csv": "^5.0.7",
        "jspdf": "^2.5.1",
        "lodash": "^4.17.21",
        "migrate-mongo": "^8.2.2",
        "mjml": "^4.10.4",
        "moment": "^2.29.1",
        "mongoose": "^5.12.12",
        "mongoose-lean-virtuals": "^0.9.1",
        "mongoose-unique-validator": "^2.0.3",
        "multer": "^1.4.4-lts.1",
        "nanoid": "^3.1.23",
        "ng-click-outside": "^8.0.0",
        "ngx-currency": "^2.5.3",
        "ngx-image-cropper": "^3.3.5",
        "ngx-mask": "^12.0.0",
        "ngx-quill": "14.3.0",
        "ngx-socket-io": "^4.1.0",
        "oauth2-server": "^3.1.1",
        "oidc-client": "^1.11.5",
        "open-iconic": "^1.1.1",
        "pdfmake": "^0.2.5",
        "querymen": "^2.1.4",
        "quill": "^1.3.7",
        "reflect-metadata": "^0.1.13",
        "rxjs": "^7.5.5",
        "signature_pad": "^3.0.0-beta.4",
        "socket.io": "^4.1.3",
        "swagger-ui-express": "^4.1.6",
        "text-mask-addons": "^3.8.0",
        "tslib": "^2.0.0",
        "uuid": "^8.3.2",
        "zone.js": "~0.11.4"
    },
    "devDependencies": {
        "@angular-devkit/architect": ">= 0.900 < 0.1300",
        "@angular-devkit/build-angular": "12.0.0",
        "@angular-eslint/eslint-plugin": "~12.0.0",
        "@angular-eslint/eslint-plugin-template": "~12.0.0",
        "@angular-eslint/template-parser": "~12.0.0",
        "@angular/cli": "12.0.0",
        "@angular/compiler-cli": "12.0.0",
        "@angular/language-service": "12.0.0",
        "@angular/localize": "12.0.0",
        "@nestjs/schematics": "^7.0.0",
        "@nestjs/testing": "^7.0.0",
        "@nrwl/cli": "12.3.4",
        "@nrwl/cypress": "12.3.4",
        "@nrwl/eslint-plugin-nx": "12.3.4",
        "@nrwl/jest": "12.3.4",
        "@nrwl/linter": "12.3.4",
        "@nrwl/nest": "^12.3.4",
        "@nrwl/node": "12.3.4",
        "@nrwl/tao": "12.3.4",
        "@nrwl/workspace": "12.3.4",
        "@types/bcryptjs": "^2.4.2",
        "@types/bull": "^3.15.9",
        "@types/continuation-local-storage": "^3.2.3",
        "@types/cron": "^1.7.3",
        "@types/express-handlebars": "^5.3.0",
        "@types/express-session": "^1.17.3",
        "@types/file-saver": "^2.0.5",
        "@types/jest": "26.0.8",
        "@types/jquery": "^3.5.14",
        "@types/jsdom": "^16.2.14",
        "@types/lodash": "^4.14.182",
        "@types/mongoose-lean-virtuals": "^0.5.3",
        "@types/mongoose-unique-validator": "^1.0.6",
        "@types/multer": "^1.4.7",
        "@types/node": "14.14.33",
        "@types/oauth2-server": "^3.0.12",
        "@types/pdfmake": "^0.1.21",
        "@types/quill": "^2.0.8",
        "@typescript-eslint/eslint-plugin": "4.19.0",
        "@typescript-eslint/parser": "4.19.0",
        "cypress": "^6.0.1",
        "dotenv": "8.2.0",
        "eslint": "7.22.0",
        "eslint-config-prettier": "8.1.0",
        "eslint-plugin-cypress": "^2.10.3",
        "firebase-tools": "^8.0.0 || ^9.0.0",
        "fuzzy": "^0.1.3",
        "husky": ">=6",
        "inquirer": "^6.2.2",
        "inquirer-autocomplete-prompt": "^1.0.1",
        "jest": "26.2.2",
        "jest-preset-angular": "8.4.0",
        "jsonc-parser": "^3.0.0",
        "lint-staged": ">=10",
        "open": "^7.0.3",
        "prettier": "2.2.1",
        "ts-jest": "26.5.5",
        "ts-node": "~9.1.1",
        "tsconfig-paths": "^3.9.0",
        "typescript": "~4.2.4"
    },
    "lint-staged": {
        "**/*.{js,json,ts,tsx,html,scss,md}": "prettier --write"
    }
}

I also added NETLIFY_USE_YARN, YARN_VERSION as document Manage build dependencies | Netlify Docs

and my repo has yarn.lock too.
but the issue still occurs.

I’m waiting for help because my site is still working and I need to update it for my client

Thank a lot

2 Likes

I have the same issue.

One of our sites was using the deprecated Ubuntu Xenial 16.04, but after changing to the new Ubuntu Focal 20.04 our deployments stopped working.

We have a yarn.lock too.

2 Likes

Same problem here. The site was built successfully yesterday 5DEC22 at 9:30am EST.

Today I went to trigger a deploy without changing any code and it returned the Yarn: Command not found error. Nothing changed since yesterday. Been running on 20.04 for a couple of weeks now without issue.

I have confirmed yarn.lock is in the repository still and even tried setting the NETLIFY_USE_YARN variable.

1 Like

@abonventre and @AstaDK I contacted Netlify about the issue (we have Netlify Pro) and they deployed a fix for it.

It’s now working on my end, I suspect it’s working on yours too.

1 Like

Thank a lot for your announce

Thank you for sharing that information here, @GonzaloHirschToptal.

@AstaDK and @abonventre, this should be resolved for everyone. However, if you still see the issue, please reply here anytime to let us know.