Problem when deploy node js project from GitHub repo CI= npm run build

6:49:21 PM: Build ready to start
6:49:23 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
6:49:23 PM: build-image tag: v3.7.6
6:49:23 PM: buildbot version: b87d14453141a3234e590bfa7e86c1c20171a78e
6:49:23 PM: Fetching cached dependencies
6:49:23 PM: Failed to fetch cache, continuing with build
6:49:23 PM: Starting to prepare the repo for build
6:49:24 PM: No cached dependencies found. Cloning fresh repo
6:49:24 PM: git clone https://github.com/amrmuhamedd/portfolio
6:49:24 PM: Preparing Git Reference refs/heads/main
6:49:25 PM: Parsing package.json dependencies
6:49:25 PM: Starting build script
6:49:25 PM: Installing dependencies
6:49:25 PM: Python version set to 2.7
6:49:27 PM: v12.18.0 is already installed.
6:49:27 PM: Now using node v12.18.0 (npm v6.14.4)
6:49:27 PM: Started restoring cached build plugins
6:49:27 PM: Finished restoring cached build plugins
6:49:27 PM: Attempting ruby version 2.7.1, read from environment
6:49:29 PM: Using ruby version 2.7.1
6:49:29 PM: Using PHP version 5.6
6:49:29 PM: Started restoring cached node modules
6:49:29 PM: Finished restoring cached node modules
6:49:29 PM: Installing NPM modules using NPM version 6.14.4
6:49:31 PM: npm WARN deprecated sendgrid@1.9.2: Please see v6.X+ at npm
6:49:31 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see Request’s Past, Present and Future Β· Issue #3142 Β· request/request Β· GitHub
6:49:33 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
6:49:35 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
6:49:36 PM: npm WARN deprecated urix@0.1.0: Please see GitHub - lydell/urix: [DEPRECATED] Makes Windows-style paths more unix and URI friendly.
6:49:36 PM: npm WARN deprecated resolve-url@0.2.1: GitHub - lydell/resolve-url: [DEPRECATED] Like Node.js’ `path.resolve`/`url.resolve` for the browser.
6:49:36 PM: npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
6:49:36 PM: npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
6:49:47 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/core-js
6:49:47 PM: > node -e β€œtry{require(’./postinstall’)}catch(e){}”
6:49:48 PM: npm notice created a lockfile as package-lock.json. You should commit this file.
6:49:48 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/chokidar/node_modules/fsevents):
6:49:48 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œlinux”,β€œarch”:β€œx64”})
6:49:48 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
6:49:48 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œlinux”,β€œarch”:β€œx64”})
6:49:48 PM: npm WARN portfolio@1.0.0 No repository field.
6:49:48 PM: added 728 packages from 514 contributors and audited 730 packages in 18.252s
6:49:49 PM: 30 packages are looking for funding
6:49:49 PM: run npm fund for details
6:49:49 PM: found 7 vulnerabilities (3 low, 1 moderate, 3 high)
6:49:49 PM: run npm audit fix to fix them, or npm audit for details
6:49:49 PM: NPM modules installed
6:49:49 PM: Started restoring cached go cache
6:49:49 PM: Finished restoring cached go cache
6:49:49 PM: go version go1.14.4 linux/amd64
6:49:49 PM: go version go1.14.4 linux/amd64
6:49:49 PM: Installing missing commands
6:49:49 PM: Verify run directory
6:49:50 PM: ​
6:49:50 PM: ────────────────────────────────────────────────────────────────
6:49:50 PM: Netlify Build
6:49:50 PM: ────────────────────────────────────────────────────────────────
6:49:50 PM: ​
6:49:50 PM: ❯ Version
6:49:50 PM: @netlify/build 11.32.5
6:49:50 PM: ​
6:49:50 PM: ❯ Flags
6:49:50 PM: deployId: 60be4e119d3a520007dde947
6:49:50 PM: ​
6:49:50 PM: ❯ Current directory
6:49:50 PM: /opt/build/repo
6:49:50 PM: ​
6:49:50 PM: ❯ Config file
6:49:50 PM: /opt/build/repo/netlify.toml
6:49:50 PM: ​
6:49:50 PM: ❯ Context
6:49:50 PM: production
6:49:50 PM: ​
6:49:50 PM: ────────────────────────────────────────────────────────────────
6:49:50 PM: 1. Build command from Netlify app
6:49:50 PM: ────────────────────────────────────────────────────────────────
6:49:50 PM: ​
6:49:50 PM: $ CI= npm run build
6:49:50 PM: > portfolio@1.0.0 build /opt/build/repo
6:49:50 PM: > netlify-lambda build src
6:49:50 PM: netlify-lambda: Building functions
6:49:51 PM: ModuleNotFoundError: Module not found: Error: Can’t resolve β€˜β€¦/controller/user-Controller.js’ in β€˜/opt/build/repo/Routes’ at /opt/build/repo/node_modules/webpack/lib/Compilation.js:925:10
6:49:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModuleFactory.js:401:22
6:49:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModuleFactory.js:130:21
6:49:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModuleFactory.js:224:22
6:49:51 PM: at /opt/build/repo/node_modules/neo-async/async.js:2830:7
6:49:51 PM: at /opt/build/repo/node_modules/neo-async/async.js:6877:13
6:49:51 PM: at /opt/build/repo/node_modules/webpack/lib/NormalModuleFactory.js:214:25
6:49:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:213:14
6:49:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:285:5
6:49:51 PM: at eval (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), :13:1)
6:49:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
6:49:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:285:5
6:49:51 PM: at eval (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), :13:1)
6:49:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:285:5
6:49:51 PM: at eval (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), :25:1)
6:49:51 PM: at /opt/build/repo/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
6:49:51 PM: resolve β€˜β€¦/controller/user-Controller.js’ in β€˜/opt/build/repo/Routes’
6:49:51 PM: using description file: /opt/build/repo/package.json (relative path: ./Routes)
6:49:51 PM: using description file: /opt/build/repo/package.json (relative path: ./controller/user-Controller.js)
6:49:51 PM: no extension
6:49:51 PM: /opt/build/repo/controller/user-Controller.js doesn’t exist .wasm
6:49:51 PM: /opt/build/repo/controller/user-Controller.js.wasm doesn’t exist .mjs
6:49:51 PM: /opt/build/repo/controller/user-Controller.js.mjs doesn’t exist .js
6:49:51 PM: /opt/build/repo/controller/user-Controller.js.js doesn’t exist .json
6:49:51 PM: /opt/build/repo/controller/user-Controller.js.json doesn’t exist .ts
6:49:51 PM: /opt/build/repo/controller/user-Controller.js.ts doesn’t exist as directory
6:49:51 PM: /opt/build/repo/controller/user-Controller.js doesn’t existnpm ERR! code ELIFECYCLE
6:49:51 PM: npm ERR! errno 1
6:49:51 PM: npm ERR! portfolio@1.0.0 build: netlify-lambda build src
6:49:51 PM: npm ERR! Exit status 1
6:49:51 PM: npm ERR!
6:49:51 PM: npm ERR! Failed at the portfolio@1.0.0 build script.
6:49:51 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
6:49:51 PM: npm ERR! A complete log of this run can be found in:
6:49:51 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-06-07T16_49_51_744Z-debug.log
6:49:51 PM: ​
6:49:51 PM: ────────────────────────────────────────────────────────────────
6:49:51 PM: β€œbuild.command” failed
6:49:51 PM: ────────────────────────────────────────────────────────────────
6:49:51 PM: ​
6:49:51 PM: Error message
6:49:51 PM: Command failed with exit code 1: CI= npm run build
6:49:51 PM: ​
6:49:51 PM: Error location
6:49:51 PM: In Build command from Netlify app:
6:49:51 PM: CI= npm run build
6:49:51 PM: ​
6:49:51 PM: Resolved config
6:49:51 PM: build:
6:49:51 PM: command: CI= npm run build
6:49:51 PM: commandOrigin: ui
6:49:51 PM: publish: /opt/build/repo/dist
6:49:51 PM: functions:
6:49:51 PM: β€˜*’: {}
6:49:51 PM: functionsDirectory: /opt/build/repo/functions
6:49:52 PM: Caching artifacts
6:49:52 PM: Started saving node modules
6:49:52 PM: Finished saving node modules
6:49:52 PM: Started saving build plugins
6:49:52 PM: Finished saving build plugins
6:49:52 PM: Started saving pip cache
6:49:52 PM: Finished saving pip cache
6:49:52 PM: Started saving emacs cask dependencies
6:49:52 PM: Finished saving emacs cask dependencies
6:49:52 PM: Started saving maven dependencies
6:49:52 PM: Finished saving maven dependencies
6:49:52 PM: Started saving boot dependencies
6:49:52 PM: Finished saving boot dependencies
6:49:52 PM: Started saving rust rustup cache
6:49:52 PM: Finished saving rust rustup cache
6:49:52 PM: Started saving go dependencies
6:49:52 PM: Finished saving go dependencies
6:49:54 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:49:54 PM: Creating deploy upload records
6:49:54 PM: Failing build: Failed to build site
6:49:54 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
6:49:54 PM: Finished processing build request in 31.738028057s

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile:

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!

This might help:

1 Like