Yarn: command not found

I’m trying to run a build of my website (haven’t done it in about 6 months but there have been no change on my part since then) and it is failing saying the yarn command wasn’t found, cf log:

Blockquote
4:43:03 PM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
4:43:03 PM: build-image tag: v4.16.3
4:43:03 PM: buildbot version: 4033cea21a3d9a6b51a0c8660e8b7502a7f7abfe
4:43:03 PM: Fetching cached dependencies
4:43:03 PM: Failed to fetch cache, continuing with build
4:43:03 PM: Starting to prepare the repo for build
4:43:03 PM: No cached dependencies found. Cloning fresh repo
4:43:03 PM: git clone --filter=blob:none git@gitlab.com:orior/orior-app
4:43:05 PM: Preparing Git Reference refs/heads/master
4:43:06 PM: Parsing package.json dependencies
4:43:07 PM: Starting build script
4:43:07 PM: Installing dependencies
4:43:07 PM: Python version set to 2.7
4:43:08 PM: Downloading and installing node v12.18.0…
4:43:08 PM: Downloading https://nodejs.org/dist/v12.18.0/node-v12.18.0-linux-x64.tar.xz
4:43:09 PM: Computing checksum with sha256sum
4:43:09 PM: Checksums matched!
4:43:10 PM: Now using node v12.18.0 (npm v6.14.4)
4:43:11 PM: Started restoring cached build plugins
4:43:11 PM: Finished restoring cached build plugins
4:43:11 PM: Attempting Ruby version 2.7.1, read from environment
4:43:11 PM: Required ruby-2.7.1 is not installed - installing.
4:43:11 PM: Searching for binary rubies, this might take some time.
4:43:11 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.7.1.tar.bz2
4:43:11 PM: Checking requirements for ubuntu.
4:43:12 PM: Requirements installation successful.
4:43:12 PM: ruby-2.7.1 - #configure
4:43:12 PM: ruby-2.7.1 - #download
4:43:12 PM: ruby-2.7.1 - #validate archive
4:43:16 PM: ruby-2.7.1 - #extract
4:43:18 PM: ruby-2.7.1 - #validate binary
4:43:19 PM: ruby-2.7.1 - #setup
4:43:19 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1@global
4:43:19 PM: ruby-2.7.1 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems…
4:43:20 PM: ruby-2.7.1 - #generating global wrappers…
4:43:20 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1
4:43:20 PM: ruby-2.7.1 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
4:43:20 PM: ruby-2.7.1 - #generating default wrappers…
4:43:20 PM: Using /opt/buildhome/.rvm/gems/ruby-2.7.1
4:43:20 PM: Using Ruby version 2.7.1
4:43:21 PM: Using PHP version 8.0
4:43:21 PM: Started restoring cached go cache
4:43:21 PM: Finished restoring cached go cache
4:43:21 PM: Installing Go version 1.14.4 (requested 1.14.4)
4:43:25 PM: unset GOOS;
4:43:25 PM: unset GOARCH;
4:43:25 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.14.4.linux.amd64’;
4:43:25 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.14.4.linux.amd64/bin:${PATH}”;
4:43:25 PM: go version >&2;
4:43:25 PM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.14.4.linux.amd64.env”
4:43:25 PM: go version go1.14.4 linux/amd64
4:43:25 PM: Detected 0 framework(s)
4:43:25 PM: Installing missing commands
4:43:25 PM: Verify run directory
4:43:25 PM: Section completed: initializing
4:43:27 PM: ​
4:43:27 PM: Netlify Build
4:43:27 PM: ────────────────────────────────────────────────────────────────
4:43:27 PM: ​
4:43:27 PM: ❯ Version
4:43:27 PM: @netlify/build 29.4.5
4:43:27 PM: ​
4:43:27 PM: ❯ Flags
4:43:27 PM: baseRelDir: true
4:43:27 PM: buildId: 63c570845b4bb3000a4ddfd1
4:43:27 PM: deployId: 63c570845b4bb3000a4ddfd3
4:43:27 PM: ​
4:43:27 PM: ❯ Current directory
4:43:27 PM: /opt/build/repo
4:43:27 PM: ​
4:43:27 PM: ❯ Config file
4:43:27 PM: No config file was defined: using default values.
4:43:27 PM: ​
4:43:27 PM: ❯ Context
4:43:27 PM: production
4:43:27 PM: ​
4:43:27 PM: 1. Build command from Netlify app
4:43:27 PM: ────────────────────────────────────────────────────────────────
4:43:27 PM: ​
4:43:27 PM: $ yarn build
4:43:27 PM: bash: yarn: command not found
4:43:27 PM: ​
4:43:27 PM: “build.command” failed
4:43:27 PM: ────────────────────────────────────────────────────────────────
4:43:27 PM: ​
4:43:27 PM: Error message
4:43:27 PM: Command failed with exit code 127: yarn build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
4:43:27 PM: ​
4:43:27 PM: Error location
4:43:27 PM: In Build command from Netlify app:
4:43:27 PM: yarn build
4:43:27 PM: ​
4:43:27 PM: Resolved config
4:43:27 PM: build:
4:43:27 PM: command: yarn build
4:43:27 PM: commandOrigin: ui
4:43:27 PM: publish: /opt/build/repo/build
4:43:27 PM: publishOrigin: ui
4:43:27 PM: Caching artifacts
4:43:27 PM: Started saving build plugins
4:43:27 PM: Finished saving build plugins
4:43:27 PM: Started saving pip cache
4:43:27 PM: Finished saving pip cache
4:43:27 PM: Started saving emacs cask dependencies
4:43:27 PM: Finished saving emacs cask dependencies
4:43:27 PM: Started saving maven dependencies
4:43:27 PM: Finished saving maven dependencies
4:43:27 PM: Started saving boot dependencies
4:43:27 PM: Finished saving boot dependencies
4:43:27 PM: Started saving rust rustup cache
4:43:27 PM: Finished saving rust rustup cache
4:43:27 PM: Started saving go dependencies
4:43:27 PM: Finished saving go dependencies
4:43:30 PM: Cached Ruby version 2.7.1
4:43:30 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:43:30 PM: Failing build: Failed to build site
4:43:30 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
4:43:30 PM: Finished processing build request in 27.57302762s
Blockquote

FTR the last time I had a successful build it was using the Xenial build image, maybe this could be linked to the change in build image?

Thanks a lot!

netlify site name: reverent-kalam-debc28.netlify.app

@amaury7 There is some Yarn specific documentation here:

It looks like you need to have a yarn.lock file or a packageManager property in your package.json that specifies yarn.

@nathanmartin thanks for your answer, I do have a yarn.lock file so there must be some other issue (also it had always worked fine and it stopped working with no action on my part…)

@amaury7 Excellent, well that’s the easy stuff checked.

Netlify’s support should be able to point you in the right direction.

@nathanmartin thanks! Is there a way for them to see this post?

Hi @amaury7 , welcome to the Netlify support forums! :wave:t6:

Have you tried updating your build command to?
CI= npm run build .

Hello @SamO thank you! I have tried indeed and strangely enough the result was exactly the same (yarn: command not found)

Hmm @amaury7 can you share your repo? And you got it working locally first?

here it is @SamO

my command to deploy is the following:

build
    netlify deploy -d build --prod -a $NETLIFY_AUTH_TOKEN -s $NETLIFY_SITE_ID

and in my Netlify settings I have yarn build and build as directory

The yarn.lock appears to in the frontend folder. Maybe you need to set that as the base path: Netlify App

For the record the issue was that I subscribed to Netlify.
The authorization between Gitlab and Netlify stopped working so I had to create a new auth token.
This should be in the docs…