Netlify not building - Command failed with exit code 1: npm run build

Hey, I can’t figure out why my app wont build on netlify. I tried building it locally it works, was checking for same file names, lowercase names that are different, tried removing json files and do a clean npm install, none helped. And it’s something related with this project. I’ve tried making a new project that only has App file inside of it and that worked, so it’s something messed up with this up I’m working on.
Here’s a github repo: GitHub - h3h394/MoviesApp
Here is the picture:

Hi, @h3h394, we released a change today which might be related:

You can test if this is the root cause by changing the build command to the version below which will unset this new CI environment variable:

CI= npm run build

If that doesn’t resolve the issue and/or if there are any questions, please let us know.

8 Likes

O my god, I spent last 4 hours removing every single thing I had and it didn’t work, installing npm again and trying all the solutions on netlify’s forum and stackoverflow. After 4 hours of not working, I’ve tried your solution and that worked the first time. Thank you so muchhhhhhhhhh <3

Same problem and this was also my issue. -_-.
Problem solved using this solution

2 Likes

How do you unset CI if using codesandbox?
Nevermind

create a netlify.toml file in the root and use this setting
[build]
command = “CI= npm run build”

thank you, i been dealing with problem too!

1 Like

Sorry. I dont understand. I have the same problem. I have to put [build]
command = “CI= npm run build” in netlify.toml? because the issue still persist

Can you explain how you did it?

hi there, please see this thread:

there are some instructions a few posts down from the top :+1:

4 Likes

This works! thank you very much!

2 Likes

Woooooo, thank you so much for this solution!!!

1 Like

thank you so much…

1 Like

Hey, i tried the CI= npm run build but it isnt working.

6:20:25 AM: ┌───────────────────────────────────┐
6:20:25 AM: │ 1. Build command from Netlify app │
6:20:25 AM: └───────────────────────────────────┘
6:20:25 AM: ​
6:20:25 AM: $ CI=npm run build
6:20:25 AM: bash: run: command not found
6:20:25 AM: ​
6:20:25 AM: ┌─────────────────────────────┐
6:20:25 AM: │ “build.command” failed │
6:20:25 AM: └─────────────────────────────┘
6:20:25 AM: ​
6:20:25 AM: Error message
6:20:25 AM: Command failed with exit code 127: CI=npm run build
6:20:25 AM: ​
6:20:25 AM: Error location
6:20:25 AM: In Build command from Netlify app:
6:20:25 AM: CI=npm run build
6:20:25 AM: ​
6:20:25 AM: Resolved config
6:20:25 AM: build:
6:20:25 AM: command: CI=npm run build
6:20:25 AM: commandOrigin: ui
6:20:25 AM: publish: /opt/build/repo/build
6:20:25 AM: Caching artifacts

1 Like

Hey i tried “CI= npm run build” but it didnt work.

Here is the error:

6:20:25 AM: ┌───────────────────────────────────┐
6:20:25 AM: │ 1. Build command from Netlify app │
6:20:25 AM: └───────────────────────────────────┘
6:20:25 AM: ​
6:20:25 AM: $ CI=npm run build
6:20:25 AM: bash: run: command not found
6:20:25 AM: ​
6:20:25 AM: ┌─────────────────────────────┐
6:20:25 AM: │ “build.command” failed │
6:20:25 AM: └─────────────────────────────┘
6:20:25 AM: ​
6:20:25 AM: Error message
6:20:25 AM: Command failed with exit code 127: CI=npm run build
6:20:25 AM: ​
6:20:25 AM: Error location
6:20:25 AM: In Build command from Netlify app:
6:20:25 AM: CI=npm run build
6:20:25 AM: ​
6:20:25 AM: Resolved config
6:20:25 AM: build:
6:20:25 AM: command: CI=npm run build
6:20:25 AM: commandOrigin: ui
6:20:25 AM: publish: /opt/build/repo/build
6:20:25 AM: Caching artifacts

CI= npm run build (check the spaces) @kennymanman :+1:

hey guys i tried everything and still cant build the app

9:25:22 AM: v12.18.0 is already installed.
9:25:23 AM: Now using node v12.18.0 (npm v6.14.4)
9:25:23 AM: Started restoring cached build plugins
9:25:23 AM: Finished restoring cached build plugins
9:25:23 AM: Attempting ruby version 2.7.1, read from environment
9:25:24 AM: Using ruby version 2.7.1
9:25:24 AM: Using PHP version 5.6
9:25:24 AM: 5.2 is already installed.
9:25:24 AM: Using Swift version 5.2
9:25:24 AM: Started restoring cached node modules
9:25:24 AM: Finished restoring cached node modules
9:25:25 AM: Installing NPM modules using NPM version 6.14.4
9:25:29 AM: > nodemon@2.0.2 postinstall /opt/build/repo/node_modules/nodemon
9:25:29 AM: > node bin/postinstall || exit 0
9:25:29 AM: Love nodemon? You can now support the project via the open collective:
9:25:29 AM: > Contribute to nodemon - Open Collective
9:25:29 AM: npm WARN chatcord@1.0.0 No repository field.
9:25:29 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
9:25:29 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
9:25:29 AM: added 198 packages from 107 contributors and audited 199 packages in 3.474s
9:25:29 AM: 1 package is looking for funding
9:25:29 AM: run npm fund for details
9:25:29 AM: found 1 high severity vulnerability
9:25:29 AM: run npm audit fix to fix them, or npm audit for details
9:25:29 AM: NPM modules installed
9:25:29 AM: Started restoring cached go cache
9:25:29 AM: Finished restoring cached go cache
9:25:29 AM: go version go1.14.4 linux/amd64
9:25:29 AM: go version go1.14.4 linux/amd64
9:25:29 AM: Installing missing commands
9:25:29 AM: Verify run directory
9:25:30 AM: ​
9:25:30 AM: ┌─────────────────────────────┐
9:25:30 AM: │ Netlify Build │
9:25:30 AM: └─────────────────────────────┘
9:25:30 AM: ​
9:25:30 AM: ❯ Version
9:25:30 AM: @netlify/build 3.0.1
9:25:30 AM: ​
9:25:30 AM: ❯ Flags
9:25:30 AM: deployId: 5f28103cff928d8cb3cb913d
9:25:30 AM: mode: buildbot
9:25:30 AM: ​
9:25:30 AM: ❯ Current directory
9:25:30 AM: /opt/build/repo
9:25:30 AM: ​
9:25:30 AM: ❯ Config file
9:25:30 AM: No config file was defined: using default values.
9:25:30 AM: ​
9:25:30 AM: ❯ Context
9:25:30 AM: production
9:25:30 AM: ​
9:25:30 AM: ┌───────────────────────────────────┐
9:25:30 AM: │ 1. Build command from Netlify app │
9:25:30 AM: └───────────────────────────────────┘
9:25:30 AM: ​
9:25:30 AM: $ CI= npm run build
9:25:31 AM: npm ERR! missing script: build
9:25:31 AM: npm ERR! A complete log of this run can be found in:
9:25:31 AM: npm ERR! /opt/buildhome/.npm/_logs/2020-08-03T13_25_31_192Z-debug.log
9:25:31 AM: ​
9:25:31 AM: ┌─────────────────────────────┐
9:25:31 AM: │ “build.command” failed │
9:25:31 AM: └─────────────────────────────┘
9:25:31 AM: ​
9:25:31 AM: Error message
9:25:31 AM: Command failed with exit code 1: CI= npm run build
9:25:31 AM: ​
9:25:31 AM: Error location
9:25:31 AM: In Build command from Netlify app:
9:25:31 AM: CI= npm run build
9:25:31 AM: ​
9:25:31 AM: Resolved config
9:25:31 AM: build:
9:25:31 AM: command: CI= npm run build
9:25:31 AM: commandOrigin: ui
9:25:31 AM: environment:
9:25:31 AM: - CI
9:25:31 AM: publish: /opt/build/repo/public
9:25:31 AM: Caching artifacts
9:25:31 AM: Started saving node modules
9:25:31 AM: Finished saving node modules
9:25:31 AM: Started saving build plugins
9:25:31 AM: Finished saving build plugins
9:25:31 AM: Started saving pip cache
9:25:31 AM: Finished saving pip cache
9:25:31 AM: Started saving emacs cask dependencies
9:25:31 AM: Finished saving emacs cask dependencies
9:25:31 AM: Started saving maven dependencies
9:25:31 AM: Finished saving maven dependencies
9:25:31 AM: Started saving boot dependencies
9:25:31 AM: Finished saving boot dependencies
9:25:31 AM: Started saving go dependencies
9:25:31 AM: Finished saving go dependencies
9:25:34 AM: Error running command: Build script returned non-zero exit code: 1
9:25:34 AM: Failing build: Failed to build site
9:25:34 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
9:25:34 AM: Finished processing build request in 15.866999081s

1 Like

this code here is the problem - we cannot run the command you are telling us to for some reason. Does this code work locally?

i just spent 4 hours as well felt like i was going to have a heart attack…i was so frustrated… then I came across CI= npm run build THAT FIXED IT in Build Settings -> Build command: CI= npm run build… I’m just happy it works!

1 Like

Hey, i tried the CI= npm run build but still doesn’t work.

hey there, can you post a screenshot of your build settings and also the content of your package.json please?