I am having a build failure when I try to deploy my site

Hi everyone, I am a newbie here.

The problem is that I am trying to publish my portfolio through Netlify but I can’t pass through the build process. Whenever I run it on my local machine using npm run build, it opens up localhost:3000/and I can see my site there.

I also tried configuring the build command to CI= npm run build but nothing changed.

Here is my netlify site name: tiny-dusk-d6ba9d.netlify.app
And here is the complete log of the deployment:

Please let me know if I need to share more details about it!

12:59:51 AM: build-image version: 50f2c07b4ff67fac131b5b345ef7efb7e0ab9dac (focal)
12:59:51 AM: buildbot version: 3c77419a32191e587913c896861b4b2804c7fa10
12:59:51 AM: Building without cache
12:59:51 AM: Starting to prepare the repo for build
12:59:52 AM: No cached dependencies found. Cloning fresh repo
12:59:52 AM: git clone --filter=blob:none https://github.com/IsmanDaiyrov/Isman_Portfolio
12:59:52 AM: Preparing Git Reference refs/heads/main
12:59:54 AM: Starting to install dependencies
12:59:54 AM: Python version set to 3.8
12:59:54 AM: Attempting Ruby version 2.7.2, read from environment
12:59:55 AM: Using Ruby version 2.7.2
12:59:55 AM: Started restoring cached go cache
12:59:55 AM: Finished restoring cached go cache
12:59:55 AM: go version go1.19.13 linux/amd64
12:59:56 AM: Using PHP version 8.0
12:59:57 AM: v18.18.2 is already installed.
12:59:57 AM: Now using node v18.18.2 (npm v9.8.1)
12:59:57 AM: Enabling Node.js Corepack
12:59:57 AM: Started restoring cached build plugins
12:59:57 AM: Finished restoring cached build plugins
12:59:57 AM: Started restoring cached corepack dependencies
12:59:57 AM: Finished restoring cached corepack dependencies
12:59:57 AM: Started restoring cached yarn cache
12:59:57 AM: Finished restoring cached yarn cache
12:59:57 AM: No yarn workspaces detected
12:59:57 AM: Started restoring cached node modules
12:59:57 AM: Finished restoring cached node modules
12:59:58 AM: Installing npm packages using Yarn version 1.22.19
12:59:58 AM: yarn install v1.22.19
12:59:58 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
12:59:58 AM: [1/4] Resolving packages...
12:59:59 AM: [2/4] Fetching packages...
1:00:14 AM: [3/4] Linking dependencies...
1:00:14 AM: warning " > @testing-library/user-event@7.2.1" has unmet peer dependency "@testing-library/dom@>=5".
1:00:14 AM: warning " > bootstrap@4.6.1" has unmet peer dependency "jquery@1.9.1 - 3".
1:00:14 AM: warning " > bootstrap@4.6.1" has unmet peer dependency "popper.js@^1.16.1".
1:00:14 AM: warning " > react-p5-wrapper@3.4.0" has incorrect peer dependency "react@>= 17.0.2".
1:00:14 AM: warning " > react-p5-wrapper@3.4.0" has incorrect peer dependency "react-dom@>= 17.0.2".
1:00:14 AM: warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
1:00:27 AM: [4/4] Building fresh packages...
1:00:28 AM: success Saved lockfile.
1:00:28 AM: Done in 30.07s.
1:00:28 AM: npm packages installed using Yarn
1:00:28 AM: Install dependencies script success
1:00:28 AM: Starting build script
1:00:29 AM: Detected 1 framework(s)
1:00:29 AM: "create-react-app" at version "3.4.3"
1:00:29 AM: Section completed: initializing
1:00:31 AM: ​
1:00:31 AM: Netlify Build                                                 
1:00:31 AM: ────────────────────────────────────────────────────────────────
1:00:31 AM: ​
1:00:31 AM: ❯ Version
1:00:31 AM:   @netlify/build 29.24.0
1:00:31 AM: ​
1:00:31 AM: ❯ Flags
1:00:31 AM:   baseRelDir: true
1:00:31 AM:   buildId: 653df4d6a2ba8c3e89d61f3f
1:00:31 AM:   deployId: 653df4d6a2ba8c3e89d61f41
1:00:31 AM: ​
1:00:31 AM: ❯ Current directory
1:00:31 AM:   /opt/build/repo
1:00:31 AM: ​
1:00:31 AM: ❯ Config file
1:00:31 AM:   No config file was defined: using default values.
1:00:31 AM: ​
1:00:31 AM: ❯ Context
1:00:31 AM:   production
1:00:31 AM: ​
1:00:31 AM: Build command from Netlify app                                
1:00:31 AM: ────────────────────────────────────────────────────────────────
1:00:31 AM: ​
1:00:31 AM: $ npm run build
1:00:31 AM: > idaiyrov@1.0.0 build
1:00:31 AM: > react-scripts build
1:00:32 AM: Creating an optimized production build...
1:00:32 AM: Error: error:0308010C:digital envelope routines::unsupported
1:00:32 AM:     at new Hash (node:internal/crypto/hash:69:19)
1:00:32 AM:     at Object.createHash (node:crypto:133:10)
1:00:32 AM:     at module.exports (/opt/build/repo/node_modules/webpack/lib/util/createHash.js:135:53)
1:00:32 AM:     at NormalModule._initBuildHash (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:417:16)
1:00:32 AM:     at handleParseError (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:471:10)
1:00:32 AM:     at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:503:5
1:00:32 AM:     at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:358:12
1:00:32 AM:     at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:373:3
1:00:32 AM:     at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
1:00:32 AM:     at iterateNormalLoaders (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
1:00:32 AM: /opt/build/repo/node_modules/react-scripts/scripts/build.js:19
1:00:32 AM:   throw err;
1:00:32 AM:   ^
1:00:32 AM: Error: error:0308010C:digital envelope routines::unsupported
1:00:32 AM:     at new Hash (node:internal/crypto/hash:69:19)
1:00:32 AM:     at Object.createHash (node:crypto:133:10)
1:00:32 AM:     at module.exports (/opt/build/repo/node_modules/webpack/lib/util/createHash.js:135:53)
1:00:32 AM:     at NormalModule._initBuildHash (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:417:16)
1:00:32 AM:     at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:452:10
1:00:32 AM:     at /opt/build/repo/node_modules/webpack/lib/NormalModule.js:323:13
1:00:32 AM:     at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:367:11
1:00:32 AM:     at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:233:18
1:00:32 AM:     at context.callback (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
1:00:32 AM:     at /opt/build/repo/node_modules/babel-loader/lib/index.js:59:103 {
1:00:32 AM:   opensslErrorStack: [ "error:03000086:digital envelope routines::initialization error" ],
1:00:32 AM:   library: "digital envelope routines",
1:00:32 AM:   reason: "unsupported",
1:00:32 AM:   code: "ERR_OSSL_EVP_UNSUPPORTED"
1:00:32 AM: }
1:00:32 AM: Node.js v18.18.2
1:00:32 AM: ​
1:00:32 AM: "build.command" failed                                        
1:00:32 AM: ────────────────────────────────────────────────────────────────
1:00:32 AM: ​
1:00:32 AM:   Error message
1:00:32 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
1:00:32 AM: ​
1:00:32 AM:   Error location
1:00:32 AM:   In Build command from Netlify app:
1:00:32 AM:   npm run build
1:00:32 AM: ​
1:00:32 AM:   Resolved config
1:00:32 AM:   build:
1:00:32 AM:     command: npm run build
1:00:32 AM:     commandOrigin: ui
1:00:32 AM:     publish: /opt/build/repo/build
1:00:32 AM:     publishOrigin: ui
1:00:33 AM: Failed during stage "building site": Build script returned non-zero exit code: 2
1:00:33 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:00:33 AM: Failing build: Failed to build site
1:00:33 AM: Finished processing build request in 42.012s

My package.json file if needed:

{
  "name": "idaiyrov",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.3",
    "@material-ui/icons": "^4.11.2",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "bootstrap": "^4.6.1",
    "or": "^0.2.0",
    "p5": "^1.5.0",
    "react": "^16.13.1",
    "react-bootstrap": "^1.6.4",
    "react-dom": "^16.13.1",
    "react-p5-wrapper": "^3.4.0",
    "react-responsive-carousel": "^3.2.23",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.3",
    "react-transition-group": "^4.4.1",
    "react-typist": "^2.0.5",
    "rsuite": "^4.8.2",
    "schema-utils": "^3.0.0",
    "three": "^0.126.1",
    "yarn": "^1.22.19"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -b master -d build"
  },
  "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"
    ]
  },
  "devDependencies": {
    "gh-pages": "^3.1.0",
    "prettier": "^2.2.1"
  },
  "homepage": "https://idaiyrov.com"
}

This isn’t a magic bullet solution.
It’s often suggested for people whose builds are failing due to thrown warnings.
By default warnings are treated as errors, and errors cause a build to fail.
In most instances people can’t be bothered fixing the cause of the warnings and just want their build to work, so setting CI= npm run build allows them to bypass the default behavior.

If your build isn’t throwing warnings it will have no impact at all.

You can read about your specific issue in this stack overflow:

1 Like

Thanks! I have tried some of the solutions that people are saying in stack overflow but I am still getting some errors with it.

@IsmanDaiyrov There may be multiple things that need to change.

These are the approximate steps that another user went through when encountering the same error:

2 Likes

Thank you! It turned out that Netlify was using Node v18 instead of v16. After changing it the error was gone!