Error Build Script

Hello everyone,

I have deployed many times without any issue, but I can’t deploy a repo because it failed on the build script with the following error:

10:30:39 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)

10:30:35 PM: Netlify Build

10:30:35 PM: ────────────────────────────────────────────────────────────────

10:30:35 PM: ​

10:30:35 PM: ❯ Version

10:30:35 PM: @netlify/build 29.12.1

10:30:35 PM: ​

10:30:35 PM: ❯ Flags

10:30:35 PM: baseRelDir: true

10:30:35 PM: buildId: 6494af3de134110ee0ec60ba

10:30:35 PM: deployId: 6494af3de134110ee0ec60bc

10:30:35 PM: ​

10:30:35 PM: ❯ Current directory

10:30:35 PM: /opt/build/repo

10:30:35 PM: ​

10:30:35 PM: ❯ Config file

10:30:35 PM: No config file was defined: using default values.

10:30:35 PM: ​

10:30:35 PM: ❯ Context

10:30:35 PM: production

10:30:35 PM: ​

10:30:35 PM: Build command from Netlify app

10:30:35 PM: ────────────────────────────────────────────────────────────────

10:30:35 PM: ​

10:30:35 PM: $ npm run build

10:30:35 PM: > vue-first-app@0.1.0 build

10:30:35 PM: > vue-cli-service build

10:30:36 PM: - Building for production…

10:30:37 PM: Error: error:0308010C:digital envelope routines::unsupported

10:30:37 PM: at new Hash (node:internal/crypto/hash:71:19)

10:30:37 PM: at Object.createHash (node:crypto:133:10)

10:30:37 PM: at module.exports (/opt/build/repo/node_modules/webpack/lib/util/createHash.js:135:53)

10:30:37 PM: at NormalModule._initBuildHash (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:417:16)

10:30:37 PM: at handleParseError (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:471:10)

10:30:37 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:503:5

10:30:37 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:358:12

10:30:37 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:373:3

10:30:37 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:214:10)

10:30:37 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:221:10)

10:30:37 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:236:3

10:30:37 PM: at runSyncOrAsync (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:130:11)

10:30:37 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:232:2)

10:30:37 PM: at Array. (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:205:4)

10:30:37 PM: at Storage.finished (/opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)

10:30:37 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9

10:30:37 PM: /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:114

10:30:37 PM: throw e;

10:30:37 PM: ^

10:30:37 PM: Error: error:0308010C:digital envelope routines::unsupported

10:30:37 PM: at new Hash (node:internal/crypto/hash:71:19)

10:30:37 PM: at Object.createHash (node:crypto:133:10)

10:30:37 PM: at module.exports (/opt/build/repo/node_modules/webpack/lib/util/createHash.js:135:53)

10:30:37 PM: at NormalModule._initBuildHash (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:417:16)

10:30:37 PM: at handleParseError (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:471:10)

10:30:37 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:503:5

10:30:37 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:358:12

10:30:37 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:373:3

10:30:37 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:214:10)

10:30:37 PM: at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:221:10)

10:30:37 PM: at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:236:3

10:30:37 PM: at context.callback (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:111:13)

10:30:37 PM: at /opt/build/repo/node_modules/cache-loader/dist/index.js:147:7

10:30:37 PM: at /opt/build/repo/node_modules/graceful-fs/graceful-fs.js:61:14

10:30:37 PM: at FSReqCallback.oncomplete (node:fs:198:23) {

10:30:37 PM: opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ],

10:30:37 PM: library: ‘digital envelope routines’,

10:30:37 PM: reason: ‘unsupported’,

10:30:37 PM: code: ‘ERR_OSSL_EVP_UNSUPPORTED’

10:30:37 PM: }

10:30:37 PM: Node.js v18.16.1

10:30:37 PM: ​

10:30:37 PM: build.command failed

10:30:37 PM: ────────────────────────────────────────────────────────────────

10:30:37 PM: ​

10:30:37 PM: Error message

10:30:37 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)

10:30:37 PM: ​

10:30:37 PM: Error location

10:30:37 PM: In Build command from Netlify app:

10:30:37 PM: npm run build

10:30:37 PM: ​

10:30:37 PM: Resolved config

10:30:37 PM: publishOrigin: ui

10:30:37 PM: build:

10:30:37 PM: command: npm run build

10:30:37 PM: commandOrigin: ui

10:30:37 PM: publish: /opt/build/repo/dist

10:30:39 PM: Build failed due to a user error: Build script returned non-zero exit code: 2

10:30:39 PM: Failing build: Failed to build site

10:30:39 PM: Finished processing build request in 32.282s

Deploying

Skipped

Cleanup

Can you please help me?
Thanks!

@danielemazzamuto In your package.json adjust your build script to have NODE_OPTIONS='--openssl-legacy-provider' at the start.

Applicable Stack Overflow answer here:

Applicable other Netlify discussion here:

Thank you Nathan, it did resolved the issue and I was able to deploy it :slight_smile:
Do you know why in some App I was able to build them without adding the NODE_OPTIONS=‘–openssl-legacy-provider’ and in this one I was not?

Thanks

@danielemazzamuto There’s more information throughout the Stack Overflow I linked to, it would depend on what you were building and the version of node being used.

1 Like