Home
Support Forums

Need advice to troubleshoot We couldn’t deploy your site

Hi! I got a problem with npm run build. I’ve tried but still can not solve this mistake while build react app with webpack
Please help me detect this
12:59:41 AM: $ npm run build
12:59:41 AM: > complex-app-react-review@1.0.0 build /opt/build/repo
12:59:41 AM: > npm-run-all -s generate webpackBuild
12:59:41 AM: > complex-app-react-review@1.0.0 generate /opt/build/repo
12:59:41 AM: > babel-node --presets=@babel/preset-react,@babel/preset-env generateHTML.js
12:59:43 AM: > complex-app-react-review@1.0.0 webpackBuild /opt/build/repo
12:59:43 AM: > webpack
12:59:43 AM: sh: 1: webpack: not found
12:59:43 AM: npm ERR! code ELIFECYCLE
12:59:43 AM: npm ERR! syscall spawn
12:59:43 AM: npm ERR! file sh
12:59:43 AM: npm ERR! errno ENOENT
12:59:43 AM: npm ERR! complex-app-react-review@1.0.0 webpackBuild: webpack
12:59:43 AM: npm ERR! spawn ENOENT
12:59:43 AM: npm ERR!
12:59:43 AM: npm ERR! Failed at the complex-app-react-review@1.0.0 webpackBuild script.
12:59:43 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:59:43 AM: npm ERR! A complete log of this run can be found in:
12:59:43 AM: npm ERR! /opt/buildhome/.npm/_logs/2021-07-04T17_59_43_771Z-debug.log
12:59:43 AM: ERROR: “webpackBuild” exited with 1.
12:59:43 AM: npm ERR! code ELIFECYCLE
12:59:43 AM: npm ERR! errno 1
12:59:43 AM: npm ERR! complex-app-react-review@1.0.0 build: npm-run-all -s generate webpackBuild
12:59:43 AM: npm ERR! Exit status 1
12:59:43 AM: npm ERR!
12:59:43 AM: npm ERR! Failed at the complex-app-react-review@1.0.0 build script.
12:59:43 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:59:43 AM: npm ERR! A complete log of this run can be found in:
12:59:43 AM: npm ERR! /opt/buildhome/.npm/_logs/2021-07-04T17_59_43_795Z-debug.log
12:59:43 AM: ​
12:59:43 AM: ────────────────────────────────────────────────────────────────
12:59:43 AM: “build.command” failed
12:59:43 AM: ────────────────────────────────────────────────────────────────
12:59:43 AM: ​
12:59:43 AM: Error message
12:59:43 AM: Command failed with exit code 1: npm run build
12:59:43 AM: ​
12:59:43 AM: Error location
12:59:43 AM: In Build command from Netlify app:
12:59:43 AM: npm run build
12:59:43 AM: ​
12:59:43 AM: Resolved config
12:59:43 AM: build:
12:59:43 AM: command: npm run build
12:59:43 AM: commandOrigin: ui
12:59:43 AM: publish: /opt/build/repo/dist
12:59:43 AM: publishOrigin: ui
12:59:43 AM: functions:
12:59:43 AM: ‘*’: {}
12:59:43 AM: redirectsOrigin: config
12:59:44 AM: Caching artifacts
12:59:44 AM: Started saving node modules
12:59:44 AM: Finished saving node modules
12:59:44 AM: Started saving build plugins
12:59:44 AM: Finished saving build plugins
12:59:44 AM: Started saving yarn cache
12:59:44 AM: Finished saving yarn cache
12:59:44 AM: Started saving pip cache
12:59:44 AM: Finished saving pip cache
12:59:44 AM: Started saving emacs cask dependencies
12:59:44 AM: Finished saving emacs cask dependencies
12:59:44 AM: Started saving maven dependencies
12:59:44 AM: Finished saving maven dependencies
12:59:44 AM: Started saving boot dependencies
12:59:44 AM: Finished saving boot dependencies
12:59:44 AM: Started saving rust rustup cache
12:59:44 AM: Finished saving rust rustup cache
12:59:44 AM: Started saving go dependencies
12:59:44 AM: Finished saving go dependencies
12:59:46 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:59:46 AM: Creating deploy upload records
12:59:46 AM: Failing build: Failed to build site
12:59:46 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
12:59:46 AM: Finished processing build request in 33.371271129s

H @TongXin,

Could you post your package.json or show your repo? Looks like your package.json is missing web pack as a dependency.

Hi @hrishikesh - this is my package json. Please help me check it :wink:

{
    "name": "complex-app-react-review",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",

    "scripts": {
        "dev": "npm-run-all -s generate webpackDev",
        "webpackDev": "webpack serve --config webpack.config.js --open",
        "build": "npm-run-all -s generate webpackBuild",
        "webpackBuild": "webpack",
        "generate": "babel-node --presets=@babel/preset-react,@babel/preset-env generateHTML.js",
        "previewDist": "node previewDist",
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "@babel/node": "^7.14.7",
        "axios": "^0.21.1",
        "babel-loader": "^8.2.2",
        "clean-webpack-plugin": "^4.0.0-alpha.0",
        "dotenv-webpack": "^7.0.3",
        "express": "^4.17.1",
        "fs-extra": "^10.0.0",
        "html-webpack-harddisk-plugin": "^2.0.0",
        "html-webpack-plugin": "^5.3.1",
        "immer": "^9.0.3",
        "npm-run-all": "^4.1.5",
        "react": "^17.0.2",
        "react-dom": "^17.0.2",
        "react-markdown": "^6.0.2",
        "react-router-dom": "^5.2.0",
        "react-tooltip": "^4.2.21",
        "react-transition-group": "^4.4.2",
        "socket.io-client": "^4.1.2",
        "use-immer": "^0.5.2",
        "webpack-dev-server": "^3.11.2"
    },
    "devDependencies": {
        "@babel/core": "^7.14.5",
        "@babel/preset-env": "^7.14.5",
        "@babel/preset-react": "^7.14.5",
        "babel-register": "^6.26.0",
        "webpack-cli": "^4.7.2"
    }
}

webpack-cli is in devDependencies. Could you move that (and possibly others too) to dependencies?

I saw netlify automatically redeploy when I follow your idea and push again, but It’s not working for me @hrishikesh,

Could you post your new build log or website’s name?

I have captured build log below:

12:14:55 PM: Build ready to start
12:14:57 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
12:14:57 PM: build-image tag: v3.8.0
12:14:57 PM: buildbot version: 47a260c724afddff188fab051570aa2ebbb35f32
12:14:57 PM: Fetching cached dependencies
12:14:57 PM: Failed to fetch cache, continuing with build
12:14:57 PM: Starting to prepare the repo for build
12:14:58 PM: No cached dependencies found. Cloning fresh repo
12:14:58 PM: git clone https://github.com/<mygithub>/<myapp>
12:14:59 PM: Preparing Git Reference refs/heads/deploy
12:15:00 PM: Parsing package.json dependencies
12:15:01 PM: Starting build script
12:15:01 PM: Installing dependencies
12:15:01 PM: Python version set to 2.7
12:15:02 PM: v12.18.0 is already installed.
12:15:03 PM: Now using node v12.18.0 (npm v6.14.4)
12:15:03 PM: Started restoring cached build plugins
12:15:03 PM: Finished restoring cached build plugins
12:15:03 PM: Attempting ruby version 2.7.2, read from environment
12:15:04 PM: Using ruby version 2.7.2
12:15:05 PM: Using PHP version 5.6
12:15:05 PM: Started restoring cached yarn cache
12:15:05 PM: Finished restoring cached yarn cache
12:15:05 PM: Installing yarn at version 1.22.10
12:15:05 PM: Installing Yarn!
12:15:05 PM: > Downloading tarball...
12:15:05 PM: [1/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz --> /tmp/yarn.tar.gz.QJyhoR167I
12:15:05 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
12:15:05 PM:                                  Dload  Upload   Total   Spent    Left  Speed
12:15:05 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
12:15:05 PM: 100    81  100    81    0     0    351      0 --:--:-- --:--:-- --:--:--   352
12:15:05 PM: 100    95  100    95    0     0    157      0 --:--:-- --:--:-- --:--:--   157
12:15:05 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
12:15:05 PM: 100   626  100   626    0     0    708      0 --:--:-- --:--:-- --:--:-- 23185
12:15:06 PM: 100 1215k  100 1215k    0     0   987k      0  0:00:01  0:00:01 --:--:--  987k
12:15:06 PM: [2/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz.asc --> /tmp/yarn.tar.gz.QJyhoR167I.asc
12:15:06 PM: 100    85  100    85    0     0   1502      0 --:--:-- --:--:-- --:--:--  1502
12:15:06 PM: 100    99  100    99    0     0   1122      0 --:--:-- --:--:-- --:--:--  1122
12:15:06 PM: 100   630  100   630    0     0   5473      0 --:--:-- --:--:-- --:--:--  5473
12:15:06 PM: 100   832  100   832    0     0   5213      0 --:--:-- --:--:-- --:--:--  5213
12:15:06 PM: > Verifying integrity...
12:15:06 PM: gpg: Signature made Fri 02 Oct 2020 11:17:27 AM UTC using RSA key ID 69475BAA
12:15:06 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
12:15:06 PM: gpg: WARNING: This key is not certified with a trusted signature!
12:15:06 PM: gpg:          There is no indication that the signature belongs to the owner.
12:15:06 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
12:15:06 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
12:15:06 PM: > GPG signature looks good
12:15:06 PM: > Extracting to ~/.yarn...
12:15:06 PM: > Adding to $PATH...
12:15:07 PM: > Successfully installed Yarn 1.22.10! Please open another terminal where the `yarn` command will now be available.
12:15:07 PM: No yarn workspaces detected
12:15:07 PM: Started restoring cached node modules
12:15:07 PM: Finished restoring cached node modules
12:15:07 PM: Installing NPM modules using Yarn version 1.22.10
12:15:08 PM: yarn install v1.22.10
12:15:08 PM: 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:15:08 PM: [1/4] Resolving packages...
12:15:08 PM: warning webpack-dev-server > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
12:15:08 PM: [2/4] Fetching packages...
12:15:19 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
12:15:19 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
12:15:19 PM: [3/4] Linking dependencies...
12:15:19 PM: warning " > babel-loader@8.2.2" has unmet peer dependency "webpack@>=2".
12:15:19 PM: warning " > clean-webpack-plugin@4.0.0-alpha.0" has unmet peer dependency "webpack@>=4.0.0 <6.0.0".
12:15:19 PM: warning " > dotenv-webpack@7.0.3" has unmet peer dependency "webpack@^4 || ^5".
12:15:19 PM: warning " > html-webpack-harddisk-plugin@2.0.0" has unmet peer dependency "webpack@^5.0.0".
12:15:19 PM: warning " > html-webpack-plugin@5.3.2" has unmet peer dependency "webpack@^5.20.0".
12:15:19 PM: warning " > react-markdown@6.0.2" has unmet peer dependency "@types/react@>=16".
12:15:19 PM: warning " > webpack-dev-server@3.11.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
12:15:19 PM: warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
12:15:19 PM: warning " > webpack-cli@4.7.2" has unmet peer dependency "webpack@4.x.x || 5.x.x".
12:15:19 PM: warning "webpack-cli > @webpack-cli/configtest@1.0.4" has unmet peer dependency "webpack@4.x.x || 5.x.x".
12:15:24 PM: [4/4] Building fresh packages...
12:15:24 PM: success Saved lockfile.
12:15:24 PM: Done in 16.80s.
12:15:24 PM: NPM modules installed using Yarn
12:15:25 PM: Started restoring cached go cache
12:15:25 PM: Finished restoring cached go cache
12:15:25 PM: go version go1.14.4 linux/amd64
12:15:25 PM: go version go1.14.4 linux/amd64
12:15:25 PM: Installing missing commands
12:15:25 PM: Verify run directory
12:15:25 PM: ​
12:15:25 PM: ────────────────────────────────────────────────────────────────
12:15:25 PM:   Netlify Build                                                 
12:15:25 PM: ────────────────────────────────────────────────────────────────
12:15:25 PM: ​
12:15:25 PM: ❯ Version
12:15:25 PM:   @netlify/build 13.3.0
12:15:25 PM: ​
12:15:25 PM: ❯ Flags
12:15:25 PM:   deployId: 60e3e6cfab3d94000942f6db
12:15:25 PM: ​
12:15:25 PM: ❯ Current directory
12:15:25 PM:   /opt/build/repo
12:15:25 PM: ​
12:15:25 PM: ❯ Config file
12:15:25 PM:   /opt/build/repo/netlify.toml
12:15:25 PM: ​
12:15:25 PM: ❯ Context
12:15:25 PM:   production
12:15:25 PM: ​
12:15:25 PM: ────────────────────────────────────────────────────────────────
12:15:25 PM:   1. Build command from Netlify app                             
12:15:25 PM: ────────────────────────────────────────────────────────────────
12:15:25 PM: ​
12:15:25 PM: $ npm run build
12:15:26 PM: > complex-app-react-review@1.0.0 build /opt/build/repo
12:15:26 PM: > npm-run-all -s generate webpackBuild
12:15:26 PM: > complex-app-react-review@1.0.0 generate /opt/build/repo
12:15:26 PM: > babel-node --presets=@babel/preset-react,@babel/preset-env generateHTML.js
12:15:28 PM: > complex-app-react-review@1.0.0 webpackBuild /opt/build/repo
12:15:28 PM: > webpack
12:15:28 PM: sh: 1: webpack: not found
12:15:28 PM: npm ERR! code ELIFECYCLE
12:15:28 PM: npm ERR! syscall spawn
12:15:28 PM: npm ERR! file sh
12:15:28 PM: npm ERR! errno ENOENT
12:15:28 PM: npm ERR! complex-app-react-review@1.0.0 webpackBuild: `webpack`
12:15:28 PM: npm ERR! spawn ENOENT
12:15:28 PM: npm ERR!
12:15:28 PM: npm ERR! Failed at the complex-app-react-review@1.0.0 webpackBuild script.
12:15:28 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:15:28 PM: npm ERR! A complete log of this run can be found in:
12:15:28 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-07-06T05_15_28_531Z-debug.log
12:15:28 PM: ERROR: "webpackBuild" exited with 1.
12:15:28 PM: npm ERR! code ELIFECYCLE
12:15:28 PM: npm ERR! errno 1
12:15:28 PM: npm ERR! complex-app-react-review@1.0.0 build: `npm-run-all -s generate webpackBuild`
12:15:28 PM: npm ERR! Exit status 1
12:15:28 PM: npm ERR!
12:15:28 PM: npm ERR! Failed at the complex-app-react-review@1.0.0 build script.
12:15:28 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:15:28 PM: npm ERR! A complete log of this run can be found in:
12:15:28 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-07-06T05_15_28_552Z-debug.log
12:15:28 PM: ​
12:15:28 PM: ────────────────────────────────────────────────────────────────
12:15:28 PM:   "build.command" failed                                        
12:15:28 PM: ────────────────────────────────────────────────────────────────
12:15:28 PM: ​
12:15:28 PM:   Error message
12:15:28 PM:   Command failed with exit code 1: npm run build
12:15:28 PM: ​
12:15:28 PM:   Error location
12:15:28 PM:   In Build command from Netlify app:
12:15:28 PM:   npm run build
12:15:28 PM: ​
12:15:28 PM:   Resolved config
12:15:28 PM:   build:
12:15:28 PM:     command: npm run build
12:15:28 PM:     commandOrigin: ui
12:15:28 PM:     publish: /opt/build/repo/dist
12:15:28 PM:     publishOrigin: ui
12:15:28 PM:   functions:
12:15:28 PM:     '*': {}
12:15:28 PM:   redirectsOrigin: config
12:15:28 PM: Caching artifacts
12:15:28 PM: Started saving node modules
12:15:28 PM: Finished saving node modules
12:15:28 PM: Started saving build plugins
12:15:28 PM: Finished saving build plugins
12:15:28 PM: Started saving yarn cache
12:15:28 PM: Finished saving yarn cache
12:15:28 PM: Started saving pip cache
12:15:29 PM: Finished saving pip cache
12:15:29 PM: Started saving emacs cask dependencies
12:15:29 PM: Finished saving emacs cask dependencies
12:15:29 PM: Started saving maven dependencies
12:15:29 PM: Finished saving maven dependencies
12:15:29 PM: Started saving boot dependencies
12:15:29 PM: Finished saving boot dependencies
12:15:29 PM: Started saving rust rustup cache
12:15:29 PM: Finished saving rust rustup cache
12:15:29 PM: Started saving go dependencies
12:15:29 PM: Finished saving go dependencies
12:15:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:15:31 PM: Creating deploy upload records
12:15:31 PM: Failing build: Failed to build site
12:15:31 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:15:31 PM: Finished processing build request in 34.440894637s

webpack is another dependency than webpack-cli which is missing from your package.json.

Thanks @hrishikesh I see my mistake, it works now
I did npm i webpack “webpack”: “^5.42.1”,

:yum:
12:44:11 PM: Site is live :sparkles:

12:44:14 PM: Build script success