Command failed with exit code 1: CI= npm run build

Viewed 23590

I've been losing my mind over this
I've used this video as reference but I'm still getting the error below
I've tried everything from Netlify Form to youtube and Stackoverflow

5:33:23 AM: ────────────────────────────────────────────────────────────────
5:33:23 AM:   "build.command" failed                                        
5:33:23 AM: ────────────────────────────────────────────────────────────────
5:33:23 AM: ​
5:33:23 AM:   Error message
5:33:23 AM:   Command failed with exit code 1: CI= npm run build
5:33:23 AM: ​
5:33:23 AM:   Error location
5:33:23 AM:   In Build command from Netlify app:
5:33:23 AM:   CI= npm run build
5:33:23 AM: ​
5:33:23 AM:   Resolved config
5:33:23 AM:   build:
5:33:23 AM:     command: CI= npm run build
5:33:23 AM:     commandOrigin: ui
5:33:23 AM:     publish: /opt/build/repo/dist

My package.json file

{
  "name": "testing",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "./node_modules/.bin/netlify-lambda serve src",
    "build": "CI= npm run build"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/<my-username>/testing.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/<my-username>/testing/issues"
  },
  "homepage": "https://github.com/<my-username>/testing#readme",
  "dependencies": {
    "express": "^4.17.1",
    "netlify-lambda": "^2.0.6",
    "serverless-http": "^2.7.0"
  }
}

My netlify.toml

[build]

functions = "functions"

Deployment settings enter image description here

What am I missing? please help I'm losing my hair over this

6 Answers

Generally, libraries that choose to fail on warnings presume their users will want to fix the issues causing the warnings. If this isn’t practical for your use case, you can override the CI variable by adding CI='' to the beginning of your site build command. For example:

CI='' npm run build

This fixed my own similar problem

I had a similar error and I found the following has fixed it.

First in your package.json you have to change your build script to "build": "react-scripts build"

It should be:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "start": "./node_modules/.bin/netlify-lambda serve src",
  "build": "react-scripts build"
},

And in your netlify deploy settings change to CI= npm build.

And make sure your publish folder exists.

I also had the same problem.

But since I added some '--openssl-legacy-provider' in the package.json file before (in order to overcome the React version incompatibility problem), I just deleted them, then the problem's gone, even CI='' was unnecessary.

Just had the exact same problem. I realized it had nothing to do with my application since the 'npm run build' (which calls react-scripts build) worked fine from my terminal.

That led me to the solution that worked, and what the answers above are all guiding towards but not explicitly saying. It is a netlify build problem and CI stands for Continuous Integration.

Within the netlify Build settings, the 'build command' should have the value 'CI= npm run build'.

That worked for me.

When npm run build fails in Netlify, it can be helpful to try building localy to see more verbose error messages.

I had a very similar error today and building localy resulted in a more helpful error message:

$ npm run build

> react-form@0.1.0 build
> set "GENERATE_SOURCEMAP=false" && react-scripts build

/home/jthetzel/src/c-core-labs/coresight-onboarding-react-checklist/node_modules/react-scripts/config/webpack.config.js:664
        new MiniCssExtractPlugin({
        ^

TypeError: MiniCssExtractPlugin is not a constructor
    at module.exports (/home/jthetzel/src/c-core-labs/coresight-onboarding-react-checklist/node_modules/react-scripts/config/webpack.config.js:664:9)
    at Object.<anonymous> (/home/jthetzel/src/c-core-labs/coresight-onboarding-react-checklist/node_modules/react-scripts/scripts/build.js:58:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Which Google led to https://github.com/facebook/create-react-app/issues/11930 .

In my particular case, there was a regression in a dependency that was fixed with:

npm install mini-css-extract-plugin@2.5.1

Hopefully, the local npm run build will help surface the underlying cause that is obfuscated in the Netlify logs.

Related