Yarn build error
April 9, 2025 · AI Conversations
: $ yarn build
4:52:56 PM: yarn run v1.22.22
4:52:56 PM: $ run-p type-check "build-only {@}" —
4:52:56 PM: /bin/sh: 1: run-p: not found
4:52:56 PM: error Command failed with exit code 127. (https://ntl.fyi/exit-code-127)
4:52:56 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
4:52:56 PM:
4:52:56 PM: "build.command" failed
4:52:56 PM: ────────────────────────────────────────────────────────────────
4:52:56 PM:
4:52:56 PM: Error message
4:52:56 PM: Command failed with exit code 127: yarn build (https://ntl.fyi/exit-code-127)
4:52:56 PM:
4:52:56 PM: Error location
4:52:56 PM: In Build command from Netlify app:
4:52:56 PM: yarn build
4:52:56 PM:
4:52:56 PM: Resolved config
4:52:56 PM: build:
4:52:56 PM: base: /opt/build/repo/dist
4:52:56 PM: command: yarn build
4:52:56 PM: commandOrigin: ui
4:52:56 PM: publish: /opt/build/repo/dist
4:52:56 PM: publishOrigin: default
4:52:57 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:52:57 PM: Failing build: Failed to build site
4:52:57 PM: Finished processing build request in 11.34s
4:52:57 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
/bin/sh: 1: run-p: not found
### 🔍 What’s causing it?
Your `yarn build` script is using `run-p`, which is a command from the `npm-run-all` package. This error means that Netlify can't find the `run-p` command because it's not installed.
—
### ✅ How to fix it
You need to install `npm-run-all` as a **dependency** or **devDependency** in your project.
Run this locally:
yarn add -D npm-run-all
or if you're using npm:
npm install --save-dev npm-run-all
Then commit and push the updated `package.json` and `yarn.lock` or `package-lock.json`.
—
### 🛠 Optional: Clean up or simplify
If you're only using `run-p` in one place and don't want the extra dependency, you can replace it with native npm scripts like:
"scripts": {
"build": "npm-run-all type-check build-only",
"type-check": "vue-tsc --noEmit",
"build-only": "vite build"
}
Or, if you're not using `type-check`:
"scripts": {
"build": "vite build"
}
—
### 🔁 Final checklist
1. Run `yarn build` locally — make sure it works.
2. Push your changes (`package.json`, `yarn.lock`).
3. Trigger a new Netlify deploy.
Let me know if you want help simplifying the build script!
"name": "frontend",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check "build-only {@}" –",
"preview": "vite preview",
"test:unit": "vitest",
"build-only": "vite build",
"type-check": "vue-tsc –build",
"lint": "eslint . –fix",
"format": "prettier –write src/"
},
"dependencies": {
"@mdi/font": "^7.4.47",
"axios": "^1.8.1",
"firebase": "^11.4.0",
"nprogress": "^0.2.0",
"pinia": "^3.0.1",
"vee-validate": "^4.15.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"vuetify": "^3.7.15"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.0",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.13.4",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue-jsx": "^4.1.1",
"@vitest/eslint-plugin": "1.1.31",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.4.0",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.7.0",
"eslint": "^9.20.1",
"eslint-plugin-vue": "^9.32.0",
"jiti": "^2.4.2",
"jsdom": "^26.0.0",
"npm-run-all2": "^7.0.2",
"prettier": "^3.5.1",
"typescript": "~5.7.3",
"vite": "^6.1.0",
"vite-plugin-vue-devtools": "^7.7.2",
"vitest": "^3.0.5",
"vue-tsc": "^2.2.2"
}
}
### 🧨 Issue:
You're using `run-p` in your `"build"` script:
"build": "run-p type-check "build-only {@}" --"
But you've installed:
"npm-run-all2": "^7.0.2"
### 🧩 Root Cause:
The correct package that provides `run-p` is **`npm-run-all`**, **not** `npm-run-all2`.
> `npm-run-all2` is an unofficial fork, and it does **not** register the `run-p` command globally unless configured explicitly, which Netlify won’t do.
—
### ✅ Solution:
#### Option 1: **Install the correct package**
Replace `npm-run-all2` with `npm-run-all`:
yarn remove npm-run-all2
yarn add -D npm-run-all
Then commit and push your updated `package.json` and `yarn.lock`.
—
#### Option 2: **Update the script to not use `run-p`**
If you want to avoid `npm-run-all`, you can replace:
"build": "run-p type-check "build-only {@}" --"
with sequential execution using `&&`:
"build": "yarn type-check && yarn build-only"
—
### 🔁 Summary
| Fix | What to Do |
|—————|——————————————|
| ✅ Preferred | `yarn add -D npm-run-all` |
| 🛠 Alternative | Change script to `yarn type-check && yarn build-only` |
Let me know if you want to keep parallel execution (what `run-p` does), and I’ll help configure that too.
$ yarn build
5:02:57 PM: yarn run v1.22.22
5:02:57 PM: $ yarn type-check && yarn build-only
5:02:57 PM: $ vue-tsc –build
5:02:57 PM: /bin/sh: 1: vue-tsc: not found
5:02:57 PM: error Command failed with exit code 127. (https://ntl.fyi/exit-code-127)
5:02:57 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
5:02:57 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
5:02:57 PM: error Command failed with exit code 127. (https://ntl.fyi/exit-code-127)
5:02:57 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
5:02:57 PM:
5:02:57 PM: "build.command" failed
5:02:57 PM: ────────────────────────────────────────────────────────────────
5:02:57 PM:
5:02:57 PM: Error message
5:02:57 PM: Command failed with exit code 127: yarn build (https://ntl.fyi/exit-code-127)
5:02:57 PM:
5:02:57 PM: Error location
5:02:57 PM: In Build command from Netlify app:
5:02:57 PM: yarn build
5:02:57 PM:
5:02:57 PM: Resolved config
5:02:57 PM: build:
5:02:57 PM: base: /opt/build/repo/dist
5:02:57 PM: command: yarn build
5:02:57 PM: commandOrigin: ui
5:02:57 PM: publish: /opt/build/repo/dist
5:02:57 PM: publishOrigin: default
5:02:57 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:02:57 PM: Failing build: Failed to build site
5:02:58 PM: Finished processing build request in 15.351s
/bin/sh: 1: vue-tsc: not found
### 🧨 Problem
Netlify can't find the `vue-tsc` binary because it's only available in `node_modules/.bin`, and Netlify isn't detecting it for some reason.
Even though your `devDependencies` include:
"vue-tsc": "^2.2.2"
It might not be installing properly because:
– Netlify uses `NODE_ENV=production` by default
– And **`devDependencies` are not installed in production**
—
### ✅ Fix Options
#### ✅ Option 1: Force install `devDependencies`
Go to **Netlify → Site Settings → Build & Deploy → Environment → Environment variables**, and add:
| Key | Value |
|————-|————|
| `NODE_ENV` | `development` |
> This will ensure that `vue-tsc` (and other dev tools like `vite`, `eslint`, etc.) are installed.
Then **redeploy** the site.
—
#### ✅ Option 2: Move `vue-tsc` to `dependencies`
If you're okay with adding a tiny build-time dev tool to your production dependencies, you can run:
yarn add vue-tsc
Then commit the updated `package.json` and `yarn.lock` and redeploy.
—
### 🧪 Temporary workaround (if you're stuck)
If type-checking isn't critical for deployment, you can comment it out in your build script:
"build": "yarn build-only"
—
Let me know which approach you prefer, and I can guide you step-by-step.
5:30:35 PM: $ vite build
5:30:35 PM: /bin/sh: 1: vite: not found
5:30:35 PM: error Command failed with exit code 127. (https://ntl.fyi/exit-code-127)
5:30:35 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
5:30:35 PM:
5:30:35 PM: "build.command" failed
5:30:35 PM: ────────────────────────────────────────────────────────────────
5:30:35 PM:
5:30:35 PM: Error message
5:30:35 PM: Command failed with exit code 127: yarn build (https://ntl.fyi/exit-code-127)
5:30:35 PM:
5:30:35 PM: Error location
5:30:35 PM: In Build command from Netlify app:
5:30:35 PM: yarn build
5:30:35 PM:
5:30:35 PM: Resolved config
5:30:35 PM: build:
5:30:35 PM: base: /opt/build/repo/dist
5:30:35 PM: command: yarn build
5:30:35 PM: commandOrigin: ui
5:30:35 PM: publish: /opt/build/repo/dist
5:30:35 PM: publishOrigin: default
5:30:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:30:35 PM: Failing build: Failed to build site
5:30:36 PM: Finished processing build request in 18.527s
5:30:36 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
{
"name": "frontend",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@mdi/font": "^7.4.47",
"@vueup/vue-quill": "^1.2.0",
"apexcharts": "^4.5.0",
"axios": "^1.8.1",
"firebase": "^11.4.0",
"firebase-admin": "^13.2.0",
"nprogress": "^0.2.0",
"pinia": "^3.0.1",
"vee-validate": "^4.15.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"vue-tabler-icons": "^2.21.0",
"vue3-apexcharts": "^1.8.0",
"vue3-perfect-scrollbar": "^2.0.0",
"vue3-print-nb": "^0.1.4",
"vuetify": "^3.7.15"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.0",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.13.4",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue-jsx": "^4.1.1",
"@vitest/eslint-plugin": "1.1.31",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.4.0",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.7.0",
"eslint": "^9.20.1",
"eslint-plugin-vue": "^9.32.0",
"jiti": "^2.4.2",
"jsdom": "^26.0.0",
"npm-run-all2": "^7.0.2",
"prettier": "^3.5.1",
"sass-embedded": "^1.86.0",
"typescript": "~5.7.3",
"vite": "^6.1.0",
"vite-plugin-vue-devtools": "^7.7.2",
"vitest": "^3.0.5",
"vue-tsc": "^2.2.8"
}
}
/bin/sh: 1: vite: not found
This is because Netlify does **not install `devDependencies`** by default (since `vite`, `vue-tsc`, etc. are all listed under `devDependencies`), and that includes the Vite CLI binary (`vite`).
—
## ✅ Fix: Tell Netlify to install `devDependencies`
You have **two simple options** — pick one:
—
### ✅ Option 1: Add an environment variable to Netlify
1. Go to **Netlify Dashboard → Site Settings → Build & deploy → Environment → Environment variables**
2. Add this variable:
| Key | Value |
|————-|—————|
| `NODE_ENV` | `development` |
3. Redeploy the site
—
### ✅ Option 2: Move `vite` to regular dependencies
Run this locally:
yarn add vite
That will move it from `devDependencies` → `dependencies`.
Then commit and push:
git add package.json yarn.lock
git commit -m "Fix: Move vite to dependencies for Netlify build"
git push
Then Netlify will install `vite` during the build.
—
## 🧪 Optional Debugging Tip
To verify what's available during Netlify build, you can add a debug script:
"scripts": {
"debug": "ls -la node_modules/.bin"
}
Then add a build command like:
yarn debug && yarn build
—
Let me know if you want to keep `vite` in devDependencies and go with the env var approach — it’s more semantically correct.
That will move it from devDependencies → dependencies.
not wokring
You have two proper ways to fix it:
—
### ✅ Option A: Force move `vite` to dependencies
1. **Remove `vite` from devDependencies**:
yarn remove vite
2. **Then add it to dependencies**:
yarn add vite
This guarantees it moves to the `"dependencies"` section in your `package.json`.
3. **Commit and push**:
git add package.json yarn.lock
git commit -m "Move vite to dependencies for Netlify"
git push
—
### ✅ Option B (Preferred): Add the environment variable instead
If you want to keep `vite` as a dev tool (which is proper), do this in **Netlify UI**:
> Netlify → Site Settings → **Build & Deploy** → **Environment** → **Environment variables**
Add:
| Key | Value |
|————-|—————|
| `NODE_ENV` | `development` |
Then redeploy. This will include all devDependencies (`vite`, `vue-tsc`, etc.) in the build.
—
Let me know if you prefer a `.nvmrc` or `.yarnrc.yml` tweak or want to switch to `pnpm` — I can help streamline for Netlify.
> frontend@0.0.0 build
5:40:04 PM: > vite build
5:40:04 PM: sh: 1: vite: not found
5:40:04 PM:
5:40:04 PM: "build.command" failed
5:40:04 PM: ────────────────────────────────────────────────────────────────
5:40:04 PM:
5:40:04 PM: Error message
5:40:04 PM: Command failed with exit code 127: npm run build (https://ntl.fyi/exit-code-127)
5:40:04 PM:
5:40:04 PM: Error location
5:40:04 PM: In Build command from Netlify app:
5:40:04 PM: npm run build
1. **It wasn’t properly installed in `dependencies`**, or
2. **Netlify didn’t actually install dependencies correctly**, or
3. **Your Netlify `build.base` or `publish` paths are incorrect**.
Let’s go step-by-step and **solve this cleanly**:
—
## ✅ Final Fix Checklist for Netlify + Vite
### ✅ 1. Confirm `vite` is in `dependencies`
Open your `package.json` and make sure **`vite` is under `"dependencies"`, not `"devDependencies"`**:
"dependencies": {
"vite": "^6.1.0",
...
}
If not, do this:
yarn remove vite
yarn add vite
—
### ✅ 2. Set correct Netlify build command
In **Netlify settings**, go to:
**Site Settings → Build & deploy → Build settings** and check:
| Key | Value |
|————–|——————|
| **Build command** | `yarn build` |
| **Publish directory** | `dist` |
Make sure `dist` exists **after running `yarn build` locally** (i.e., your `vite.config.js` outputs to `dist`).
—
### ✅ 3. Clear cache and redeploy
From your Netlify dashboard:
– Go to **Deploys**
– Click **"Trigger deploy" → "Clear cache and deploy site"**
—
### ✅ 4. Optional: Log debug output
You can temporarily add this to your build script in `package.json` to debug inside Netlify:
"scripts": {
"build": "echo 'Checking vite location' && ls -la node_modules/.bin && vite build"
}
It will show if `vite` is missing from `.bin`.
—
## ✅ Summary
If you've:
– Moved `vite` to `"dependencies"`
– Set build command to `yarn build`
– Publish dir to `dist`
– Cleared cache before deploying
… then your build should work. If it still fails, please copy your latest `package.json` and **Netlify Build Settings**, and I’ll walk through line-by-line with you.
"name": "frontend",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@mdi/font": "^7.4.47",
"@vueup/vue-quill": "^1.2.0",
"apexcharts": "^4.5.0",
"axios": "^1.8.1",
"firebase": "^11.4.0",
"firebase-admin": "^13.2.0",
"nprogress": "^0.2.0",
"pinia": "^3.0.1",
"vee-validate": "^4.15.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"vue-tabler-icons": "^2.21.0",
"vue3-apexcharts": "^1.8.0",
"vue3-perfect-scrollbar": "^2.0.0",
"vue3-print-nb": "^0.1.4",
"vuetify": "^3.7.15"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.0",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.13.4",
"@vitejs/plugin-vue": "^5.2.1",
"@vitejs/plugin-vue-jsx": "^4.1.1",
"@vitest/eslint-plugin": "1.1.31",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.4.0",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.7.0",
"eslint": "^9.20.1",
"eslint-plugin-vue": "^9.32.0",
"jiti": "^2.4.2",
"jsdom": "^26.0.0",
"npm-run-all2": "^7.0.2",
"prettier": "^3.5.1",
"sass-embedded": "^1.86.0",
"typescript": "~5.7.3",
"vite": "^6.2.5",
"vite-plugin-vue-devtools": "^7.7.2",
"vitest": "^3.0.5",
"vue-tsc": "^2.2.8"
}
}
—
## ✅ 100% Working Solution
To solve this **once and for all**, you have **two solid options**:
—
### ✅ Option 1 (Preferred): Keep `vite` in `devDependencies`, and configure Netlify properly
**Step 1: Add `NODE_ENV=development` to Netlify**
Go to:
Netlify Dashboard → Site settings → Build & deploy → Environment → Environment variables
Add:
| Key | Value |
|————-|—————|
| `NODE_ENV` | `development` |
**Step 2: Clear Netlify cache and trigger redeploy**
– Go to **Deploys** tab in Netlify
– Click **“Trigger deploy” → “Clear cache and deploy site”**
—
### ✅ Option 2: Move Vite to `dependencies`
If you prefer this method, do the following:
1. Remove Vite from `devDependencies`:
yarn remove vite
2. Add it as a production dependency:
yarn add vite
3. Confirm it moved in your `package.json` like this:
"dependencies": {
...
"vite": "^6.2.5"
}
4. Then commit and push:
git add package.json yarn.lock
git commit -m "Move vite to dependencies for Netlify"
git push
—
### 🔍 Bonus Tip: Debug Script
You can also add a debug step in your build script to verify Vite is being installed:
"scripts": {
"build": "ls -la node_modules/.bin && vite build"
}
—
Let me know which method you’re going with, and I’ll stick around to confirm your next deploy works 🚀
To force it into **`dependencies`**, you need to explicitly move it using one of the two methods below:
—
### ✅ Option 1: Manually edit `package.json`
1. Open your `package.json`
2. **Cut** this line from `"devDependencies"`:
"vite": "^6.2.5"
3. **Paste it inside `"dependencies"`** instead
4. Save the file
Then run:
yarn install
This ensures Vite is in the correct section and properly linked in `.bin`.
—
### ✅ Option 2: Use `npm` to install into dependencies (even in a Yarn project)
npm install vite
npm will place it in `"dependencies"` correctly. After that, continue using Yarn.
—
### ✅ Then: Commit and Deploy
git add package.json yarn.lock
git commit -m "Move vite to dependencies for Netlify"
git push
And in **Netlify**, ensure:
– Build command: `yarn build`
– Publish directory: `dist`
—
Let me know if you want to revert to the cleaner solution with `NODE_ENV=development` instead.