‘bash: yarn: command not found’ error

callbetter.netlify.app

For the records deploy works many time and you can check this on callbetter.netlify.app, today I pushed some changes on master branch and noticed that deploy does not pass even that it earlier did many times with the same configuration

LOGS:

2:44:50 PM: Build ready to start
2:44:52 PM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41
2:44:52 PM: build-image tag: v3.5.0
2:44:52 PM: buildbot version: cc43e42ec44f57fc7c434bc20ef842caf4073be1
2:44:52 PM: Fetching cached dependencies
2:44:52 PM: Starting to download cache of 94.4MB
2:44:54 PM: Finished downloading cache in 1.661143817s
2:44:54 PM: Starting to extract cache
2:44:56 PM: Finished extracting cache in 2.956234954s
2:44:57 PM: Finished fetching cache in 4.648271539s
2:44:57 PM: Starting to prepare the repo for build
2:44:57 PM: Preparing Git Reference refs/heads/master
2:44:59 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘client’ versus ‘’ in the Netlify UI
2:44:59 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘client/build’ versus ‘’ in the Netlify UI
2:44:59 PM: Different build command detected, going to use the one specified in the Netlify configuration file: ‘yarn build’ versus ‘’ in the Netlify UI
2:44:59 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: ‘git diff --quiet HEAD^ HEAD .’
2:45:00 PM: Starting build script
2:45:00 PM: Installing dependencies
2:45:00 PM: Python version set to 2.7
2:45:00 PM: Started restoring cached node version
2:45:03 PM: Finished restoring cached node version
2:45:04 PM: v12.18.0 is already installed.
2:45:05 PM: Now using node v12.18.0 (npm v6.14.4)
2:45:05 PM: Started restoring cached build plugins
2:45:05 PM: Finished restoring cached build plugins
2:45:05 PM: Attempting ruby version 2.7.1, read from environment
2:45:07 PM: Using ruby version 2.7.1
2:45:07 PM: Using PHP version 5.6
2:45:07 PM: Started restoring cached node modules
2:45:07 PM: Finished restoring cached node modules
2:45:08 PM: Installing NPM modules using NPM version 6.14.4
2:45:09 PM: npm WARN deprecated <@>types/date-fns<@>2.6.0: This is a stub types definition for date-fns date-fns provides its own type definitions, so you don’t need <@>types/date-fns installed!
2:45:09 PM: npm WARN deprecated <@>types/axios<@>0.14.0: This is a stub types definition for axios . axios provides its own type definitions, so you don’t need <@>types/axios installed!
2:45:13 PM: npm WARN deprecated debug<@>4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. ()
2:45:17 PM: npm WARN deprecated chokidar<@>2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
2:45:21 PM: npm WARN deprecated fsevents<@>1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
2:45:22 PM: npm WARN deprecated rollup-plugin-babel<@>4.4.0: This package has been deprecated and is no longer maintained. Please use <@>rollup/plugin-babel.
2:45:22 PM: npm WARN deprecated <@>hapi/joi<@>15.1.1: Switch to ‘npm install joi’
2:45:25 PM: npm WARN deprecated urix<@>0.1.0:
2:45:26 PM: npm WARN deprecated <@>hapi/address<@>2.1.4: Moved to ‘npm install <@>sideway/address’
2:45:26 PM: npm WARN deprecated <@>hapi/topo<@>3.1.6: This version has been deprecated and is no longer supported or maintained
2:45:26 PM: npm WARN deprecated <@>hapi/hoek<@>8.5.1: This version has been deprecated and is no longer supported or maintained
2:45:26 PM: npm WARN deprecated <@>hapi/bourne<@>1.3.2: This version has been deprecated and is no longer supported or maintained
2:45:27 PM: npm WARN deprecated resolve-url<@>0.2.1:
2:45:28 PM: npm WARN deprecated request<@>2.88.2: request has been deprecated, see
2:45:28 PM: npm WARN deprecated request-promise-native<@>1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see
2:45:28 PM: npm WARN deprecated core-js<@>2.6.12: core-js<@><3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js<@>3.
2:45:28 PM: npm WARN deprecated har-validator<@>5.1.5: this library is no longer supported
2:46:12 PM: > core-js<@>2.6.12 postinstall /opt/build/repo/client/node_modules/babel-runtime/node_modules/core-js
2:46:12 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
2:46:12 PM: > core-js<@>3.8.0 postinstall /opt/build/repo/client/node_modules/core-js
2:46:12 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
2:46:12 PM: > core-js-pure<@>3.8.0 postinstall /opt/build/repo/client/node_modules/core-js-pure
2:46:12 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
2:46:12 PM: > ejs<@>2.7.4 postinstall /opt/build/repo/client/node_modules/ejs
2:46:12 PM: > node ./postinstall.js
2:46:15 PM: npm notice created a lockfile as package-lock.json. You should commit this file.
2:46:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents<@>^2.1.3 (node_modules/react-scripts/node_modules/fsevents):
2:46:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents<@>2.2.1: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:46:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents<@>~2.1.2 (node_modules/chokidar/node_modules/fsevents):
2:46:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents<@>2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:46:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents<@>^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
2:46:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents<@>1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:46:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents<@>^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
2:46:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents<@>1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:46:15 PM: npm WARN <@>material-ui/core<@>4.11.0 requires a peer of react<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/core<@>4.11.0 requires a peer of react-dom<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/icons<@>5.0.0-alpha.4 requires a peer of <@>material-ui/core<@>^5.0.0-alpha.1 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/icons<@>5.0.0-alpha.4 requires a peer of react<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/icons<@>5.0.0-alpha.4 requires a peer of react-dom<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN notistack<@>1.0.2 requires a peer of react<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN notistack<@>1.0.2 requires a peer of react-dom<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/styles<@>4.11.1 requires a peer of react<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/styles<@>4.11.1 requires a peer of react-dom<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/system<@>4.9.14 requires a peer of react<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/system<@>4.9.14 requires a peer of react-dom<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/utils<@>4.10.2 requires a peer of react<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN <@>material-ui/utils<@>4.10.2 requires a peer of react-dom<@>^16.8.0 but none is installed. You must install peer dependencies yourself.
2:46:15 PM: npm WARN tsutils<@>3.17.1 requires a peer of typescript<@>>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
2:46:15 PM: added 1943 packages from 896 contributors, updated 1 package and audited 1953 packages in 66.716s
2:46:17 PM: 127 packages are looking for funding
2:46:17 PM: run npm fund for details
2:46:17 PM: found 0 vulnerabilities
2:46:17 PM: NPM modules installed
2:46:17 PM: Started restoring cached go cache
2:46:17 PM: Finished restoring cached go cache
2:46:17 PM: go version go1.14.4 linux/amd64
2:46:17 PM: go version go1.14.4 linux/amd64
2:46:17 PM: Installing missing commands
2:46:17 PM: Verify run directory
2:46:20 PM: ​
2:46:20 PM: ────────────────────────────────────────────────────────────────
2:46:20 PM: Netlify Build
2:46:20 PM: ────────────────────────────────────────────────────────────────
2:46:20 PM: ​
2:46:20 PM: ❯ Version
2:46:20 PM: <@>netlify/build 5.4.0
2:46:20 PM: ​
2:46:20 PM: ❯ Flags
2:46:20 PM: deployId: 5fc79a52ef67b60007f209a9
2:46:20 PM: mode: buildbot
2:46:20 PM: ​
2:46:20 PM: ❯ Current directory
2:46:20 PM: /opt/build/repo/client
2:46:20 PM: ​
2:46:20 PM: ❯ Config file
2:46:20 PM: /opt/build/repo/netlify.toml
2:46:20 PM: ​
2:46:20 PM: ❯ Context
2:46:20 PM: production
2:46:20 PM: ​
2:46:20 PM: ────────────────────────────────────────────────────────────────
2:46:20 PM: 1. build.command from netlify.toml
2:46:20 PM: ────────────────────────────────────────────────────────────────
2:46:20 PM: ​
2:46:20 PM: $ yarn build
2:46:20 PM: bash: yarn: command not found
2:46:20 PM: ​
2:46:20 PM: ────────────────────────────────────────────────────────────────
2:46:20 PM: “build.command” failed
2:46:20 PM: ────────────────────────────────────────────────────────────────
2:46:20 PM: ​
2:46:20 PM: Error message
2:46:20 PM: Command failed with exit code 127: yarn build
2:46:20 PM: ​
2:46:20 PM: Error location
2:46:20 PM: In build.command from netlify.toml:
2:46:20 PM: yarn build
2:46:20 PM: ​
2:46:20 PM: Resolved config
2:46:20 PM: build:
2:46:20 PM: base: /opt/build/repo/client
2:46:20 PM: command: yarn build
2:46:20 PM: commandOrigin: config
2:46:20 PM: ignore: git diff --quiet HEAD^ HEAD .
2:46:20 PM: publish: /opt/build/repo/client/build
2:46:20 PM: redirects:
2:46:20 PM: - from: /* status: 200 to: /index.htmlCaching artifacts
2:46:20 PM: Started saving node modules
2:46:20 PM: Finished saving node modules
2:46:20 PM: Started saving build plugins
2:46:20 PM: Finished saving build plugins
2:46:20 PM: Started saving pip cache
2:46:20 PM: Finished saving pip cache
2:46:20 PM: Started saving emacs cask dependencies
2:46:20 PM: Finished saving emacs cask dependencies
2:46:20 PM: Started saving maven dependencies
2:46:20 PM: Finished saving maven dependencies
2:46:20 PM: Started saving boot dependencies
2:46:20 PM: Finished saving boot dependencies
2:46:20 PM: Started saving go dependencies
2:46:20 PM: Finished saving go dependencies
2:46:20 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:46:20 PM: Failing build: Failed to build site
2:46:20 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
2:46:20 PM: Finished processing build request in 1m28.483980855s

I’m using yarn workspace
Project structure:

callbetter
├── clinet
├── package.json
├── server
└── yarn.lock

yarn don’t have yarn.lock per workspce - it have just one in root directory of project

client/package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "<@>material-ui/core": "4.11.0",
    "<@>material-ui/icons": "5.0.0-alpha.4",
    "<@>testing-library/jest-dom": "^5.11.4",
    "<@>testing-library/react": "^11.1.0",
    "<@>testing-library/user-event": "^12.1.10",
    "axios": "^0.21.0",
    "date-fns": "^2.16.1",
    "dotenv": "^8.2.0",
    "lodash": "^4.17.20",
    "notistack": "^1.0.2",
    "peerjs": "^1.3.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router-dom": "5.1.2",
    "react-scripts": "4.0.1",
    "react-transition-group": "^4.4.1",
    "socket.io-client": "3.0.3",
    "styled-components": "^5.2.1",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "<@>types/axios": "^0.14.0",
    "<@>types/date-fns": "^2.6.0",
    "<@>types/jest": "^26.0.15",
    "<@>types/lodash": "^4.14.165",
    "<@>types/node": "^12.0.0",
    "<@>types/react": "^16.9.53",
    "<@>types/react-dom": "^16.9.8",
    "<@>types/react-router-dom": "5.1.5",
    "<@>types/react-transition-group": "^4.4.0",
    "<@>types/socket.io-client": "^1.4.34",
    "<@>types/styled-components": "^5.1.4"
  }
}

callbetter/package.json

{
“private”: true,
“workspaces”: [
“client”,
“server”
],
“name”: “callbetter”,
“version”: “1.0.0”,
“main”: “index.js”,
“author”:""
“license”: “MIT”,
“scripts”: {
“start:client”: “yarn workspace client start”,
“start:server”: “yarn workspace server devStart”,
“build:client”: “yarn workspace client build”,
“build:server”: “yarn workspace server build”,
“start”: “concurrently ‘yarn start:client’ ‘yarn start:server’”,
“build”: “concurrently ‘yarn build:client’ ‘yarn build:server’”,
“build:dockerServer”: “docker build --tag=“callbetter:server” .”,
“build:dockerCompose”: “docker-compose build”,
“start:dockerServer”: " docker run -e MONGO_PASSWORD=callbetterAdmin -p 5000:5000 -d callbetter:server",
“start:dockerCompose”: “docker-compose up”,
“lint”: “eslint --fix .”,
“fix”: “./scripts/lint.sh --fix”
},
“devDependencies”: {
“<@>typescript-eslint/eslint-plugin”: “^4.6.1”,
“<@>typescript-eslint/parser”: “^4.6.1”,
“eslint”: “^7.13.0”,
“eslint-config-prettier”: “^6.15.0”,
“eslint-config-vazco”: “^5.3.1”,
“eslint-plugin-import”: “^2.22.1”,
“eslint-plugin-jsx-a11y”: “^6.4.1”,
“eslint-plugin-prettier”: “^3.1.4”,
“eslint-plugin-react”: “^7.21.5”,
“eslint-plugin-react-hooks”: “^4.2.0”,
“eslint-plugin-vazco”: “^1.0.0”,
“husky”: “^4.3.0”,
“jira-smart-commit”: “^1.1.2”,
“prettier”: “^2.1.2”,
“remark-cli”: “^9.0.0”,
“remark-preset-lint-recommended”: “^5.0.0”,
“ts-node-dev”: “^1.0.0”,
“typescript”: “4.0.5”
},
“engines”: {
“node”: “12.x”
},
“husky”: {
“hooks”: {
“commit-msg”: “jira-smart-commit CAL”,
“pre-commit”: “yarn fix && remark -i .gitignore --use preset-lint-recommended .”
}
},
“dependencies”: {
“concurrently”: “^5.3.0”
}
}

netlify.toml

[build]
ignore = “git diff --quiet HEAD^ HEAD .”
base = “client”
command = “yarn build”
publish = “build”
[[redirects]]
from = “/*”
to = “/index.html”
status = 200

Hey there,
Apologies for the long delay here! I just took a look at your deploy logs and it seems you were able to get this working since writing in :tada: I noticed that your current netlify.toml is the same, so I’m wondering if you wouldn’t mind sharing your fix in case others run into the same thing?