Command failed with exit code 1: npm run build

Hello, I am trying to deploy my react app but getting some error. Please help me resolve this issue

Netlify Build
11:16:50 PM: ────────────────────────────────────────────────────────────────
11:16:50 PM: ​
11:16:50 PM: ❯ Version
11:16:50 PM: @netlify/build 29.16.0
11:16:50 PM: ​
11:16:50 PM: ❯ Flags
11:16:50 PM: baseRelDir: true
11:16:50 PM: buildId: 64aedfe09040a500ae81f0f8
11:16:50 PM: deployId: 64aedfe09040a500ae81f0fa
11:16:50 PM: ​
11:16:50 PM: ❯ Current directory
11:16:50 PM: /opt/build/repo
11:16:50 PM: ​
11:16:50 PM: ❯ Config file
11:16:50 PM: No config file was defined: using default values.
11:16:50 PM: ​
11:16:50 PM: ❯ Context
11:16:50 PM: production
11:16:50 PM: ​
11:16:50 PM: Build command from Netlify app
11:16:50 PM: ────────────────────────────────────────────────────────────────
11:16:50 PM: ​
11:16:50 PM: $ npm run build
11:16:50 PM: > first@0.1.0 build
11:16:50 PM: > react-scripts build
11:16:51 PM: Creating an optimized production build…
11:16:51 PM: Error: error:0308010C:digital envelope routines::unsupported
11:16:51 PM: at new Hash (node:internal/crypto/hash:71:19)
11:16:51 PM: at Object.createHash (node:crypto:133:10)
11:16:51 PM: at module.exports (/opt/build/repo/node_modules/webpack/lib/util/createHash.js:90:53)
11:16:51 PM: at NormalModule._initBuildHash (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:386:16)
11:16:51 PM: at handleParseError (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:434:10)
11:16:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:466:5
11:16:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:327:12
11:16:51 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:373:3
11:16:51 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
11:16:51 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
11:16:51 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:236:3
11:16:51 PM: at runSyncOrAsync (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
11:16:51 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
11:16:51 PM: at Array. (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
11:16:51 PM: at Storage.finished (/opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
11:16:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
11:16:51 PM: /opt/build/repo/node_modules/react-scripts/scripts/build.js:19
11:16:51 PM: throw err;
11:16:51 PM: ^
11:16:51 PM: Error: error:0308010C:digital envelope routines::unsupported
11:16:51 PM: at new Hash (node:internal/crypto/hash:71:19)
11:16:51 PM: at Object.createHash (node:crypto:133:10)
11:16:51 PM: at module.exports (/opt/build/repo/node_modules/webpack/lib/util/createHash.js:90:53)
11:16:51 PM: at NormalModule._initBuildHash (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:386:16)
11:16:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:418:10
11:16:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:293:13
11:16:51 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:367:11
11:16:51 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:233:18
11:16:51 PM: at context.callback (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
11:16:51 PM: at /opt/build/repo/node_modules/babel-loader/lib/index.js:51:103 {
11:16:51 PM: opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ],
11:16:51 PM: library: ‘digital envelope routines’,
11:16:51 PM: reason: ‘unsupported’,
11:16:51 PM: code: ‘ERR_OSSL_EVP_UNSUPPORTED’
11:16:51 PM: }
11:16:51 PM: Node.js v18.16.1
11:16:51 PM: ​
11:16:51 PM: build.command failed
11:16:51 PM: ────────────────────────────────────────────────────────────────
11:16:51 PM: ​
11:16:51 PM: Error message
11:16:51 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
11:16:51 PM: ​
11:16:51 PM: Error location
11:16:51 PM: In Build command from Netlify app:
11:16:51 PM: npm run build
11:16:51 PM: ​
11:16:51 PM: Resolved config
11:16:51 PM: build:
11:16:51 PM: command: npm run build
11:16:51 PM: commandOrigin: ui
11:16:51 PM: publish: /opt/build/repo/dist
11:16:51 PM: publishOrigin: ui
11:16:53 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
11:16:53 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:16:53 PM: Failing build: Failed to build site
11:16:54 PM: Finished processing build request in 31.049s

Your issues lie here. Can you please have a looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • any error messages you have received in your terminal window or in the developer console

I found a solution
I edited the build command to ‘CI= npm run build’ and it worked
thanks

1 Like

Hi :wave:t6: , thanks for reaching back and and sharing your solution!