My build command stopped working randomly.
Here’s the error message.
I’ve tried:
CI=yarn build
CI=yarn run build
CI=true yarn run build
but none work.
6:07:48 PM: ┌───────────────────────────────────┐
6:07:48 PM: │ 1. Build command from Netlify app │
6:07:48 PM: └───────────────────────────────────┘
6:07:48 PM:
6:07:48 PM: $ CI=true yarn run build
6:07:48 PM: yarn run v1.22.4
6:07:48 PM: warning package.json: No license field
6:07:48 PM: error Command "build" not found.
6:07:48 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
6:07:48 PM:
6:07:48 PM: ┌─────────────────────────────┐
6:07:48 PM: │ "build.command" failed │
6:07:48 PM: └─────────────────────────────┘
6:07:48 PM:
6:07:48 PM: Error message
6:07:48 PM: Command failed with exit code 1: CI=true yarn run build
6:07:48 PM:
6:07:48 PM: Error location
6:07:48 PM: In Build command from Netlify app:
6:07:48 PM: CI=yarn build
6:07:48 PM:
6:07:48 PM: Resolved config
6:07:48 PM: build:
6:07:48 PM: command: CI=true yarn run build
6:07:48 PM: commandOrigin: ui
6:07:48 PM: publish: /opt/build/repo/build
6:07:48 PM: Caching artifacts
6:07:48 PM: Started saving node modules
6:07:48 PM: Finished saving node modules
Here’s my package.json:
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
...
perry
November 16, 2020, 6:08pm
2
Hiya, sorry you are having trouble with your build.
This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem
We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!
If you are still having problems, please provide as much information as you can. Thanks!
Thanks but this doesn’t address my issue.
My build was working fine until Oct 19. Then it suddenly stopped building. The error messages don’t say why.
Not sure if this will help, but, you can try using npm. From my experience, these package managers tend to fail sometimes and using an alternative till then helps.
Thanks. What specific command should I use?
CI=true npm run build
CI=npm run build
I’m not sure what CI = true
does as I’ve never used it. But, a simple npm run build
builds the app in most cases.
jen
November 19, 2020, 11:47pm
7
Hey @acrainier1 ,
If you stick with yarn, then CI= yarn run build
with a space between =
and build
should do it. Here’s our announcement of the change from June:
Beginning on June 15, 2020 Netlify will start a gradual rollout of adding the environment variable CI to build environments, with the value of true . This environment variable, short for Continuous Integration, is commonly set in various CI environments like Travis CI and Github Actions, among many others. The ecosystem has largely agreed to use this environment setting to detect when a build is executing in a CI environment, as opposed to a local development environment.
This setting allows…
Let us know which way you go and if you run into any other issues!
Thank you Jen but it’s still failing. It says build command not found, but afaik I have a build command in package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
LOGS:
7:33:56 PM: ────────────────────────────────────────────────────────────────
7:33:56 PM: Netlify Build
7:33:56 PM: ────────────────────────────────────────────────────────────────
7:33:56 PM:
7:33:56 PM: ❯ Version
7:33:56 PM: @netlify/build 5.3.2
7:33:56 PM:
7:33:56 PM: ❯ Flags
7:33:56 PM: deployId: 5fb70edde1370a00d337edd7
7:33:56 PM: mode: buildbot
7:33:56 PM:
7:33:56 PM: ❯ Current directory
7:33:56 PM: /opt/build/repo
7:33:56 PM:
7:33:56 PM: ❯ Config file
7:33:56 PM: No config file was defined: using default values.
7:33:56 PM:
7:33:56 PM: ❯ Context
7:33:56 PM: production
7:33:56 PM:
7:33:56 PM: ────────────────────────────────────────────────────────────────
7:33:56 PM: 1. Build command from Netlify app
7:33:56 PM: ────────────────────────────────────────────────────────────────
7:33:56 PM:
7:33:56 PM: $ CI= yarn run build
7:33:57 PM: yarn run v1.22.4
7:33:57 PM: warning package.json: No license field
7:33:57 PM: error Command "build" not found.
7:33:57 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:33:57 PM:
7:33:57 PM: ────────────────────────────────────────────────────────────────
7:33:57 PM: "build.command" failed
7:33:57 PM: ────────────────────────────────────────────────────────────────
7:33:57 PM:
7:33:57 PM: Error message
7:33:57 PM: Command failed with exit code 1: CI= yarn run build
7:33:57 PM:
7:33:57 PM: Error location
7:33:57 PM: In Build command from Netlify app:
7:33:57 PM: CI= yarn run build
7:33:57 PM:
7:33:57 PM: Resolved config
7:33:57 PM: build:
7:33:57 PM: command: CI= yarn run build
7:33:57 PM: commandOrigin: ui
7:33:57 PM: publish: /opt/build/repo/build
7:33:57 PM: Caching artifacts
7:33:57 PM: Started saving node modules
7:33:57 PM: Finished saving node modules
jen
November 20, 2020, 12:49am
9
Can you please share your package.json here? Maybe there’s a syntax error or something that’s preventing it from being picked up. Are you able to build locally?
It builds locally with both npm run build
and yarn build
.
I’m actually looking to host the frontend of this site on Netflix so I wanna make sure that the continuous deployment is production safe for me.
package.json
{
"name": "kanjiremastered",
"homepage": "http://opensourcejapan.com/",
"version": "0.1.0",
"private": true,
"dependencies": {
"@auth0/auth0-react": "^1.1.0",
"@rebass/forms": "^4.0.6",
"@rebass/preset": "^4.0.5",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.3",
"@testing-library/user-event": "^7.1.2",
"bootstrap": "^4.5.2",
"emotion-theming": "^10.0.19",
"react": "^16.12.0",
"react-bootstrap": "^1.3.0",
"react-dom": "^16.12.0",
"react-icons": "^3.11.0",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.1",
"react-scroll": "^1.7.14",
"react-syntax-highlighter": "^15.3.0",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "^1.8.5",
"rebass": "^4.0.7",
"styled-components": "^5.2.0",
"wanakana": "^4.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
jen
November 20, 2020, 1:16am
11
Seems like your base directory got unset? Your site is currently using the root directory’s package.json… which indeed has no build command! But your frontend_react_app
directory’s package.json does have a build command. Can you try setting your base to be frontend_react_app
? You can do that here: Netlify App
Thanks but it’s still failing even after setting base dir to frontend_react_app
.
10:03:54 PM: ────────────────────────────────────────────────────────────────
10:03:54 PM: Netlify Build
10:03:54 PM: ────────────────────────────────────────────────────────────────
10:03:54 PM:
10:03:54 PM: ❯ Version
10:03:54 PM: @netlify/build 5.3.2
10:03:54 PM:
10:03:54 PM: ❯ Flags
10:03:54 PM: deployId: 5fb73187e242c30008e0f47f
10:03:54 PM: mode: buildbot
10:03:54 PM:
10:03:54 PM: ❯ Current directory
10:03:54 PM: /opt/build/repo/frontend_react_app
10:03:54 PM:
10:03:54 PM: ❯ Config file
10:03:54 PM: No config file was defined: using default values.
10:03:54 PM:
10:03:54 PM: ❯ Context
10:03:54 PM: production
10:03:54 PM:
10:03:54 PM: ────────────────────────────────────────────────────────────────
10:03:54 PM: 1. Build command from Netlify app
10:03:54 PM: ────────────────────────────────────────────────────────────────
10:03:54 PM:
10:03:54 PM: $ CI= yarn run build
10:03:54 PM: bash: yarn: command not found
10:03:54 PM:
10:03:54 PM: ────────────────────────────────────────────────────────────────
10:03:54 PM: "build.command" failed
10:03:54 PM: ────────────────────────────────────────────────────────────────
10:03:54 PM:
10:03:54 PM: Error message
10:03:54 PM: Command failed with exit code 127: CI= yarn run build
10:03:54 PM:
10:03:54 PM: Error location
10:03:54 PM: In Build command from Netlify app:
10:03:54 PM: CI= yarn run build
10:03:54 PM:
10:03:54 PM: Resolved config
10:03:54 PM: build:
10:03:54 PM: base: /opt/build/repo/frontend_react_app
10:03:54 PM: command: CI= yarn run build
10:03:54 PM: commandOrigin: ui
10:03:54 PM: publish: /opt/build/repo/frontend_react_app/build
10:03:54 PM: Caching artifacts
10:03:54 PM: Started saving node modules
10:03:54 PM: Finished saving node modules
fool
November 29, 2020, 11:21pm
13
This would mean that you have no yarn.lock in the frontend_react_app
directory - without it, we don’t install yarn and you cannot run it.
If you cannot move yarn.lock there, perhaps package.json with only yarn in it (/frontend_react_app/package.json
) would be a good step to get yarn installed, though you will need to point yarn to your yarn.lock file rather than running it without any arguments, in that case.
If you want to use any yarn command in your build process then included yarn.lock in your root directory. Even an empty file of yarn.lock will work fine.
1 Like