0

My Netlify Deployment is failed due to build issue : I m trying to deploy this site directly from my Github repository.

Here is the complete log :

4:03:47 PM: Build ready to start
4:03:49 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
4:03:49 PM: build-image tag: v3.7.6
4:03:49 PM: buildbot version: 96f6c6faf398b8f2b7e39c2c3c6a03ac4592e535
4:03:49 PM: Fetching cached dependencies
4:03:49 PM: Failed to fetch cache, continuing with build
4:03:49 PM: Starting to prepare the repo for build
4:03:50 PM: No cached dependencies found. Cloning fresh repo
4:03:50 PM: git clone https://github.com/Ashumaurya/sorting
4:03:50 PM: Preparing Git Reference refs/heads/master
4:03:51 PM: Parsing package.json dependencies
4:03:52 PM: Starting build script
4:03:52 PM: Installing dependencies
4:03:52 PM: Python version set to 2.7
4:03:53 PM: Downloading and installing node v10.11.0...
4:03:53 PM: Downloading https://nodejs.org/dist/v10.11.0/node-v10.11.0-linux-x64.tar.xz...
4:03:54 PM: Computing checksum with sha256sum
4:03:54 PM: Checksums matched!
4:03:56 PM: Now using node v10.11.0 (npm v6.4.1)
4:03:56 PM: Started restoring cached build plugins
4:03:56 PM: Finished restoring cached build plugins
4:03:56 PM: Attempting ruby version 2.7.1, read from environment
4:03:57 PM: Using ruby version 2.7.1
4:03:57 PM: Using PHP version 5.6
4:03:57 PM: Started restoring cached node modules
4:03:57 PM: Finished restoring cached node modules
4:03:58 PM: Installing NPM modules using NPM version 6.4.1
4:04:24 PM: > [email protected] postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js-pure
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > [email protected] postinstall /opt/build/repo/node_modules/ejs
4:04:25 PM: > node ./postinstall.js
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/webpack-dev-server/node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/watchpack-chokidar2/node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: added 1979 packages from 762 contributors and audited 1982 packages in 28.912s
4:04:27 PM: found 1269 vulnerabilities (170 moderate, 1099 high)
4:04:27 PM: run `npm audit fix` to fix them, or `npm audit` for details
4:04:27 PM: NPM modules installed
4:04:27 PM: Started restoring cached go cache
4:04:27 PM: Finished restoring cached go cache
4:04:27 PM: go version go1.14.4 linux/amd64
4:04:27 PM: go version go1.14.4 linux/amd64
4:04:27 PM: Installing missing commands
4:04:27 PM: Verify run directory
4:04:29 PM: ​
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: Netlify Build 
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: ​
4:04:29 PM: ❯ Version
4:04:29 PM: @netlify/build 11.18.0
4:04:29 PM: ​
4:04:29 PM: ❯ Flags
4:04:29 PM: deployId: 60aa2f8b1d35c500072a653d
4:04:29 PM: ​
4:04:29 PM: ❯ Current directory
4:04:29 PM: /opt/build/repo
4:04:29 PM: ​
4:04:29 PM: ❯ Config file
4:04:29 PM: /opt/build/repo/netlify.toml
4:04:29 PM: ​
4:04:29 PM: ❯ Context
4:04:29 PM: production
4:04:29 PM: ​
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: 1. Build command from Netlify app 
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: ​
4:04:29 PM: $ npm run build
4:04:29 PM: > [email protected] build /opt/build/repo
4:04:29 PM: > react-scripts build
4:04:31 PM: Creating an optimized production build...
4:04:42 PM: Failed to compile.
4:04:42 PM: 
4:04:42 PM: createRequire is not a function
4:04:42 PM: Referenced from: BaseConfig
4:04:42 PM: npm ERR! code ELIFECYCLE
4:04:42 PM: npm ERR! errno 1
4:04:42 PM: npm ERR! [email protected] build: `react-scripts build`
4:04:42 PM: npm ERR! Exit status 1
4:04:42 PM: npm ERR!
4:04:42 PM: npm ERR! Failed at the [email protected] build script.
4:04:42 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4:04:42 PM: npm ERR! A complete log of this run can be found in:
4:04:42 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-05-23T10_34_42_160Z-debug.log
4:04:42 PM: ​
4:04:42 PM: ────────────────────────────────────────────────────────────────
4:04:42 PM: "build.command" failed 
4:04:42 PM: ────────────────────────────────────────────────────────────────
4:04:42 PM: ​
4:04:42 PM: Error message
4:04:42 PM: Command failed with exit code 1: npm run build
4:04:42 PM: ​
4:04:42 PM: Error location
4:04:42 PM: In Build command from Netlify app:
4:04:42 PM: npm run build
4:04:42 PM: ​
4:04:42 PM: Resolved config
4:04:42 PM: build:
4:04:42 PM: command: npm run build
4:04:42 PM: commandOrigin: ui
4:04:42 PM: environment:
4:04:42 PM: - NODE_VERSION
4:04:42 PM: - YARN_VERSION
4:04:42 PM: - NPM_VERSION
4:04:42 PM: publish: /opt/build/repo/build
4:04:42 PM: Caching artifacts
4:04:42 PM: Started saving node modules
4:04:42 PM: Finished saving node modules
4:04:42 PM: Started saving build plugins
4:04:42 PM: Finished saving build plugins
4:04:42 PM: Started saving pip cache
4:04:42 PM: Finished saving pip cache
4:04:42 PM: Started saving emacs cask dependencies
4:04:42 PM: Finished saving emacs cask dependencies
4:04:42 PM: Started saving maven dependencies
4:04:42 PM: Finished saving maven dependencies
4:04:42 PM: Started saving boot dependencies
4:04:42 PM: Finished saving boot dependencies
4:04:42 PM: Started saving rust rustup cache
4:04:42 PM: Finished saving rust rustup cache
4:04:42 PM: Started saving go dependencies
4:04:42 PM: Finished saving go dependencies
4:04:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:04:45 PM: Creating deploy upload records
4:04:46 PM: Failing build: Failed to build site
4:04:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:04:46 PM: Finished processing build request in 56.362135788s

and here is My Package.json :

{
 "name": "sorting",
 "version": "0.1.0",
 "private": true,
 "dependencies": {
 "@babel/core": "^7.14.3",
 "@testing-library/jest-dom": "^5.11.8",
 "@testing-library/react": "^11.2.3",
 "@testing-library/user-event": "^12.6.0",
 "babel-eslint": "^10.1.0",
 "emailjs-com": "^2.6.4",
 "eslint-config-react-app": "^6.0.0",
 "react": "^17.0.1",
 "react-dom": "^17.0.1",
 "react-router-dom": "^5.2.0",
 "react-scripts": "4.0.1",
 "typescript": "^4.2.4",
 "web-vitals": "^0.2.4"
 },
 "scripts": {
 "start": "react-scripts start",
 "build": "react-scripts build",
 "test": "react-scripts test",
 "eject": "react-scripts eject"
 },
 "eslintConfig": {
 "extends": [
 "react-app",
 "react-app/jest"
 ]
 },
 "browserslist": {
 "production": [
 ">0.2%",
 "not dead",
 "not op_mini all"
 ],
 "development": [
 "last 1 chrome version",
 "last 1 firefox version",
 "last 1 safari version"
 ]
 }
}

I tried couple of things but it didn't worked. It would be really helpful if someone can explain me what is the error and how to solve it. Thankyou

Jagan Kaartik
5902 gold badges7 silver badges16 bronze badges
asked May 23, 2021 at 10:45

1 Answer 1

4

Seems like the node version v10.11.0 is the issue.

All you have to do is,

Either set a NODE_VERSION environment variable higher than 10.12.0

or

Add a .node-version or .nvmrc file to the site’s base directory in your repository and specify a higher version.

Configure Builds (Netlify): https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript

or

Use a netlify.toml file and specify as shown below.

[build.environment]
 NODE_VERSION = "14.17.0"

References: https://medium.com/@PhilipAndrews/error-eslint-typeerror-createrequire-is-not-a-function-15890e9942f7

answered May 23, 2021 at 17:01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.