Home
Support Forums

Deploy failed on netlify but it works on my local machine

Hello everyone! Netlify is really amazing and I am planning to use netlify more often throughout my learning journey.

I’ve faced a slight issue deploying my work from my git repository, it’s my first time deploying a website using webpack and nodes in general. I have to mention to you all that building the website on my local machine using “npm run build” works perfectly fine but it seems to have some issue when I try to deploy it on netlify.

I must say that I can’t share you the website since it failed to deploy but this is my git repo in case you guys can have a look to help me figure out the problem I am facing.

Sadly, It won’t let me upload images because I’m a new user but below is the log.

Here is a full build log just in case guys!

9:01:26 PM: Build ready to start
9:01:31 PM: build-image version: c5b01a919d3e16af69445c5de0cacb49efbb1a23 (focal)
9:01:31 PM: build-image tag: v4.4.0
9:01:31 PM: buildbot version: 9deea8f876b3228119111d3a654f519dd1866bfe
9:01:31 PM: Fetching cached dependencies
9:01:31 PM: Failed to fetch cache, continuing with build
9:01:31 PM: Starting to prepare the repo for build
9:01:31 PM: No cached dependencies found. Cloning fresh repo
9:01:31 PM: git clone https://github.com/Alpsboy-Jin/K-Tour
9:01:32 PM: Preparing Git Reference refs/heads/main
9:01:33 PM: Parsing package.json dependencies
9:01:34 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'dist' versus 'dist/' in the Netlify UI
9:01:34 PM: Starting build script
9:01:34 PM: Installing dependencies
9:01:34 PM: Python version set to 2.7
9:01:35 PM: Downloading and installing node v16.13.0...
9:01:35 PM: Downloading https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.xz...
9:01:35 PM: Computing checksum with sha256sum
9:01:36 PM: Checksums matched!
9:01:39 PM: Now using node v16.13.0 (npm v8.1.0)
9:01:39 PM: Started restoring cached build plugins
9:01:39 PM: Finished restoring cached build plugins
9:01:39 PM: Attempting ruby version 2.7.2, read from environment
9:01:41 PM: Using ruby version 2.7.2
9:01:41 PM: Using PHP version 8.0
9:01:41 PM: Started restoring cached node modules
9:01:41 PM: Finished restoring cached node modules
9:01:42 PM: Installing NPM modules using NPM version 8.1.0
9:01:43 PM: npm WARN old lockfile
9:01:43 PM: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
9:01:43 PM: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
9:01:43 PM: npm WARN old lockfile
9:01:43 PM: npm WARN old lockfile This is a one-time fix-up, please be patient...
9:01:43 PM: npm WARN old lockfile
9:01:52 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
9:01:54 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:01:56 PM: added 441 packages, and audited 442 packages in 14s
9:01:56 PM: 88 packages are looking for funding
9:01:56 PM:   run `npm fund` for details
9:01:56 PM: found 0 vulnerabilities
9:01:56 PM: NPM modules installed
9:01:56 PM: Started restoring cached go cache
9:01:56 PM: Finished restoring cached go cache
9:01:56 PM: go version go1.16.5 linux/amd64
9:01:57 PM: go version go1.16.5 linux/amd64
9:01:57 PM: Installing missing commands
9:01:57 PM: Verify run directory
9:01:58 PM: ​
9:01:58 PM: ────────────────────────────────────────────────────────────────
9:01:58 PM:   Netlify Build                                                 
9:01:58 PM: ────────────────────────────────────────────────────────────────
9:01:58 PM: ​
9:01:58 PM: ❯ Version
9:01:58 PM:   @netlify/build 18.20.1
9:01:58 PM: ​
9:01:58 PM: ❯ Flags
9:01:58 PM:   baseRelDir: true
9:01:58 PM:   buildId: 617e859639ce6fa500a201de
9:01:58 PM:   deployId: 617e859639ce6fa500a201e0
9:01:58 PM: ​
9:01:58 PM: ❯ Current directory
9:01:58 PM:   /opt/build/repo
9:01:58 PM: ​
9:01:58 PM: ❯ Config file
9:01:58 PM:   No config file was defined: using default values.
9:01:58 PM: ​
9:01:58 PM: ❯ Context
9:01:58 PM:   production
9:01:58 PM: ​
9:01:58 PM: ────────────────────────────────────────────────────────────────
9:01:58 PM:   1. Build command from Netlify app                             
9:01:58 PM: ────────────────────────────────────────────────────────────────
9:01:58 PM: ​
9:01:58 PM: $ npm run build
9:01:59 PM: > recommendationapp@1.0.0 build
9:01:59 PM: > webpack
9:02:01 PM: assets by info 4.06 MiB [immutable]
9:02:01 PM:   asset 0c1e50a51114c8a53c8653ae09392135.PNG 3.92 MiB [emitted] [immutable] [from: src/app/asset/1.PNG] (auxiliary name: main)
9:02:01 PM:   asset 93434108f0b41c8aeddae5356641e59f.png 143 KiB [emitted] [immutable] [from: src/app/asset/5.png] (auxiliary name: main)
9:02:01 PM: asset main.js 373 KiB [emitted] (name: main)
9:02:01 PM: asset index.html 43.2 KiB [emitted]
9:02:01 PM: runtime modules 1.98 KiB 6 modules
9:02:01 PM: modules by path ./node_modules/ 294 KiB
9:02:01 PM:   modules by path ./node_modules/xmlbuilder/lib/*.js 127 KiB 33 modules
  modules by path ./node_modules/style-loader/dist/runtime/*.js 5.75 KiB 6 modules
  modules by path ./node_modules/xml2js/lib/*.js 20.4 KiB 6 modules
  modules by path ./node_modules/css-loader/dist/runtime/*.js 2.33 KiB 2 modules
  modules by path ./node_modules/string_decoder/ 10.7 KiB 2 modules
modules by path ./src/ 13.7 KiB
  modules by path ./src/app/ 8.09 KiB
    modules by path ./src/app/*.js 7.93 KiB 8 modules
    modules by path ./src/app/asset/ 160 bytes 2 modules
  modules by path ./src/*.css 5.03 KiB
    ./src/app.css 1.11 KiB [built] [code generated]
    ./node_modules/css-loader/dist/cjs.js!./src/app.css 3.92 KiB [built] [code generated]
  ./src/index.js 559 bytes [built] [code generated]

ERROR in ./src/app/pageConstructor.js 2:0-32
Module not found: Error: Can't resolve './asset/2.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 3:0-34
Module not found: Error: Can't resolve './asset/3.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 4:0-33
Module not found: Error: Can't resolve './asset/4.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 6:0-32
Module not found: Error: Can't resolve './asset/6.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 7:0-34
Module not found: Error: Can't resolve './asset/7.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 8:0-34
Module not found: Error: Can't resolve './asset/8.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 9:0-34
Module not found: Error: Can't resolve './asset/31.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 10:0-33
Module not found: Error: Can't resolve './asset/32.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 11:0-36
Module not found: Error: Can't resolve './asset/33.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 12:0-36
Module not found: Error: Can't resolve './asset/34.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 13:0-38
Module not found: Error: Can't resolve './asset/35.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 14:0-38
Module not found: Error: Can't resolve './asset/36.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 15:0-37
Module not found: Error: Can't resolve './asset/37.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 16:0-37
Module not found: Error: Can't resolve './asset/38.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/pageConstructor.js 17:0-39
Module not found: Error: Can't resolve './asset/39.png' in '/opt/build/repo/src/app'
 @ ./src/app/request.js 2:0-42 31:5-14
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

ERROR in ./src/app/request.js 1:0-35
Module not found: Error: Can't resolve '../apikey' in '/opt/build/repo/src/app'
 @ ./src/app/regionHover.js 4:0-35 56:4-14
 @ ./src/index.js 3:0-53 24:0-16

16 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.59.1 compiled with 16 errors in 1347 ms
​
9:02:01 PM: ────────────────────────────────────────────────────────────────
9:02:01 PM:   "build.command" failed                                        
9:02:01 PM: ────────────────────────────────────────────────────────────────
9:02:01 PM: ​
9:02:01 PM:   Error message
9:02:01 PM:   Command failed with exit code 1: npm run build
9:02:01 PM: ​
9:02:01 PM:   Error location
9:02:01 PM:   In Build command from Netlify app:
9:02:01 PM:   npm run build
9:02:01 PM: ​
9:02:01 PM:   Resolved config
9:02:01 PM:   build:
9:02:01 PM:     command: npm run build
9:02:01 PM:     commandOrigin: ui
9:02:01 PM:     publish: /opt/build/repo/dist
9:02:01 PM:     publishOrigin: ui
9:02:01 PM: Caching artifacts
9:02:01 PM: Started saving node modules
9:02:01 PM: Finished saving node modules
9:02:01 PM: Started saving build plugins
9:02:01 PM: Finished saving build plugins
9:02:01 PM: Started saving pip cache
9:02:01 PM: Finished saving pip cache
9:02:01 PM: Started saving emacs cask dependencies
9:02:01 PM: Finished saving emacs cask dependencies
9:02:01 PM: Started saving maven dependencies
9:02:01 PM: Finished saving maven dependencies
9:02:01 PM: Started saving boot dependencies
9:02:01 PM: Finished saving boot dependencies
9:02:01 PM: Started saving rust rustup cache
9:02:01 PM: Finished saving rust rustup cache
9:02:01 PM: Started saving go dependencies
9:02:01 PM: Finished saving go dependencies
9:02:04 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:02:04 PM: Creating deploy upload records
9:02:04 PM: Failing build: Failed to build site
9:02:04 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
9:02:04 PM: Finished processing build request in 33.579883377s

Your file extensions seem to be in caps:

(however, some are lower cased too)

Thus the error. The case in the import statement should be same as the file name.

Awesome! I will give that a try right away.
As you have mentioned, I have just realized on my import statements that PNG is all written in lowercase.
Thank you very much for calling out my issue!
I will let you know how it goes!

Thank you for your help, its working all good now :slight_smile: