Deployment with Netlify

Deploy URL: Netlify App

Hi there,
I have an issue where I cannot deploy my website after the changes I made. I integrated stripe API and had to rewire React app because of web pack 5 and the support for polyfills. I tried clearing the cache, adding CI and giving it a value of ‘false’ in the environment variable section, changed my theme (apparently themes may cause these issues) and I did read lots of forums with similar issues, but none of the solutions worked. I will appreciate any help. Thank you and here is the error I am getting:

4:28:48 PM: build-image version: d7b3813f01c06610bc1723ff1b22446513ee7941 (focal)
4:28:48 PM: build-image tag: v4.14.3
4:28:48 PM: buildbot version: be0925a1b4e8f8d2c5a767f3e0decf8856cad273
4:28:48 PM: Building without cache
4:28:48 PM: Starting to prepare the repo for build
4:28:48 PM: No cached dependencies found. Cloning fresh repo
4:28:48 PM: git clone GitHub - magedmohammed834/crwn-clothing: E-commerce site for a clothing company
4:28:49 PM: Preparing Git Reference refs/heads/main
4:28:49 PM: Parsing package.json dependencies
4:28:50 PM: Starting build script
4:28:50 PM: Installing dependencies
4:28:50 PM: Python version set to 2.7
4:28:50 PM: Downloading and installing node v16.18.1…
4:28:50 PM: Downloading https://nodejs.org/dist/v16.18.1/node-v16.18.1-linux-x64.tar.xz
4:28:51 PM: Computing checksum with sha256sum
4:28:51 PM: Checksums matched!
4:28:53 PM: Now using node v16.18.1 (npm v8.19.2)
4:28:53 PM: Enabling node corepack
4:28:53 PM: Started restoring cached build plugins
4:28:53 PM: Finished restoring cached build plugins
4:28:53 PM: Attempting ruby version 2.7.2, read from environment
4:28:53 PM: Using ruby version 2.7.2
4:28:54 PM: Using PHP version 8.0
4:28:54 PM: Started restoring cached go cache
4:28:54 PM: Finished restoring cached go cache
4:28:54 PM: Installing Go version 1.17 (requested 1.17)
4:28:58 PM: unset GOOS;
4:28:58 PM: unset GOARCH;
4:28:58 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.17.linux.amd64’;
4:28:58 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}”;
4:28:58 PM: go version >&2;
4:28:58 PM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.17.linux.amd64.env”
4:28:58 PM: go version go1.17 linux/amd64
4:28:58 PM: Detected 0 framework(s)
4:28:58 PM: Installing missing commands
4:28:58 PM: Verify run directory
4:29:00 PM:
4:29:00 PM: ────────────────────────────────────────────────────────────────
4:29:00 PM: Netlify Build
4:29:00 PM: ────────────────────────────────────────────────────────────────
4:29:00 PM:
4:29:00 PM: ❯ Version
4:29:00 PM: @netlify/build 28.1.13
4:29:00 PM:
4:29:00 PM: ❯ Flags
4:29:00 PM: baseRelDir: true
4:29:00 PM: buildId: 636d6d0e1b30553a2c12263e
4:29:00 PM: deployId: 636d6d0e1b30553a2c122640
4:29:00 PM:
4:29:00 PM: ❯ Current directory
4:29:00 PM: /opt/build/repo
4:29:00 PM:
4:29:00 PM: ❯ Config file
4:29:00 PM: No config file was defined: using default values.
4:29:00 PM:
4:29:00 PM: ❯ Context
4:29:00 PM: production
4:29:00 PM:
4:29:00 PM: ────────────────────────────────────────────────────────────────
4:29:00 PM: 1. Build command from Netlify app
4:29:00 PM: ────────────────────────────────────────────────────────────────
4:29:00 PM:
4:29:00 PM: $ CI= npm run build
4:29:00 PM: npm ERR! code ENOENT
4:29:00 PM: npm ERR! syscall open
4:29:00 PM: npm ERR! path /opt/build/repo/package.json
4:29:00 PM: npm ERR! errno -2
4:29:00 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
4:29:00 PM: npm ERR! enoent This is related to npm not being able to find a file.
4:29:00 PM: npm ERR! enoent
4:29:00 PM: npm ERR! A complete log of this run can be found in:
4:29:00 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-11-10T21_29_00_250Z-debug-0.log
4:29:00 PM:
4:29:01 PM: Creating deploy upload records
4:29:00 PM: ────────────────────────────────────────────────────────────────
4:29:00 PM: “build.command” failed
4:29:00 PM: ────────────────────────────────────────────────────────────────
4:29:00 PM:
4:29:01 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
4:29:00 PM: Error message
4:29:00 PM: Command failed with exit code 254: CI= npm run build (Search results for '"non-zero exit code: 254"' - Netlify Support Forums)
4:29:00 PM:
4:29:00 PM: Error location
4:29:00 PM: In Build command from Netlify app:
4:29:00 PM: CI= npm run build
4:29:00 PM:
4:29:00 PM: Resolved config
4:29:00 PM: build:
4:29:00 PM: command: CI= npm run build
4:29:00 PM: commandOrigin: ui
4:29:00 PM: environment:
4:29:00 PM: - CI
4:29:00 PM: - REACT_APP_STRIPE_PUBLISHABLE_KEY
4:29:00 PM: - STRIPE_SECRET_KEY
4:29:00 PM: publish: /opt/build/repo/build
4:29:00 PM: publishOrigin: ui
4:29:00 PM: Caching artifacts
4:29:00 PM: Started saving build plugins
4:29:00 PM: Finished saving build plugins
4:29:00 PM: Started saving pip cache
4:29:00 PM: Finished saving pip cache
4:29:00 PM: Started saving emacs cask dependencies
4:29:00 PM: Finished saving emacs cask dependencies
4:29:00 PM: Started saving maven dependencies
4:29:00 PM: Finished saving maven dependencies
4:29:00 PM: Started saving boot dependencies
4:29:00 PM: Finished saving boot dependencies
4:29:00 PM: Started saving rust rustup cache
4:29:00 PM: Finished saving rust rustup cache
4:29:00 PM: Started saving go dependencies
4:29:00 PM: Finished saving go dependencies
4:29:01 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:29:01 PM: Failing build: Failed to build site
4:29:01 PM: Finished processing build request in 13.411067984s

Hi @magedmohammed834, thanks for the post and welcome.

Netlify build is looking for the package.json at the root of your repo and not finding it.

In the Netlify site build settings page when deploying the application, you should set the base directory to the directory that contains your package.json file.

Looking at your repo, the base directory should probably be crwn-clothing/ .

I think you will also need to update your publish directory to be crown-clothing/build when you are deploying the application.

Let me know the outcome after you try the suggestions above.

Thanks.

Hi clarnx,

I did what you suggested, but I still get an error message when deploying. Here it is:

build-image version: d7b3813f01c06610bc1723ff1b22446513ee7941 (focal)

9:09:12 AM: build-image tag: v4.14.3

9:09:12 AM: buildbot version: be0925a1b4e8f8d2c5a767f3e0decf8856cad273

9:09:12 AM: Fetching cached dependencies

9:09:12 AM: Starting to download cache of 152.3MB

9:09:13 AM: Finished downloading cache in 848.46418ms

9:09:13 AM: Starting to extract cache

9:09:15 AM: Finished extracting cache in 1.786843928s

9:09:15 AM: Finished fetching cache in 2.690345501s

9:09:15 AM: Starting to prepare the repo for build

9:09:15 AM: Preparing Git Reference refs/heads/main

9:09:15 AM: Parsing package.json dependencies

9:09:16 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘crwn-clothing’ versus ‘crwn-clothing/’ in the Netlify UI

9:09:16 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘crwn-clothing/build’ versus ‘build’ in the Netlify UI

9:09:16 AM: Different functions path detected, going to use the one specified in the Netlify configuration file: ‘crwn-clothing/netlify/functions’ versus ‘’ in the Netlify UI

9:09:17 AM: Starting build script

9:09:17 AM: Installing dependencies

9:09:17 AM: Python version set to 2.7

9:09:17 AM: Started restoring cached node version

9:09:18 AM: Finished restoring cached node version

9:09:19 AM: Downloading and installing node v16.18.1…

9:09:19 AM: Downloading https://nodejs.org/dist/v16.18.1/node-v16.18.1-linux-x64.tar.xz…

9:09:19 AM: Computing checksum with sha256sum

9:09:19 AM: Checksums matched!

9:09:21 AM: Now using node v16.18.1 (npm v8.19.2)

9:09:21 AM: Enabling node corepack

9:09:21 AM: Started restoring cached build plugins

9:09:21 AM: Finished restoring cached build plugins

9:09:21 AM: Attempting ruby version 2.7.2, read from environment

9:09:22 AM: Using ruby version 2.7.2

9:09:22 AM: Using PHP version 8.0

9:09:23 AM: No npm workspaces detected

9:09:23 AM: Started restoring cached node modules

9:09:23 AM: Finished restoring cached node modules

9:09:23 AM: Installing NPM modules using NPM version 8.19.2

9:09:26 AM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

9:09:36 AM: added 240 packages, removed 216 packages, changed 246 packages, and audited 1583 packages in 13s

9:09:36 AM: 233 packages are looking for funding

9:09:36 AM: run npm fund for details

9:09:36 AM: 6 high severity vulnerabilities

9:09:36 AM: To address all issues (including breaking changes), run:

9:09:36 AM: npm audit fix --force

9:09:36 AM: Run npm audit for details.

9:09:36 AM: NPM modules installed

9:09:36 AM: Creating package sha

9:09:37 AM: Started restoring cached go cache

9:09:37 AM: Finished restoring cached go cache

9:09:37 AM: Installing Go version 1.17 (requested 1.17)

9:09:41 AM: unset GOOS;

9:09:41 AM: unset GOARCH;

9:09:41 AM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.17.linux.amd64’;

9:09:41 AM: export PATH=“/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}”;

9:09:41 AM: go version >&2;

9:09:41 AM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.17.linux.amd64.env”

9:09:41 AM: go version go1.17 linux/amd64

9:09:41 AM: Detected 1 framework(s)

9:09:41 AM: “create-react-app” at version “5.0.1”

9:09:41 AM: Installing missing commands

9:09:41 AM: Verify run directory

9:09:42 AM:

9:09:42 AM: ────────────────────────────────────────────────────────────────

9:09:42 AM: Netlify Build

9:09:42 AM: ────────────────────────────────────────────────────────────────

9:09:42 AM:

9:09:42 AM: ❯ Version

9:09:42 AM: @netlify/build 28.1.13

9:09:42 AM:

9:09:42 AM: ❯ Flags

9:09:42 AM: baseRelDir: true

9:09:42 AM: buildId: 636fa901a988d66a067c7cba

9:09:42 AM: deployId: 636fa901a988d66a067c7cbc

9:09:42 AM:

9:09:42 AM: ❯ Current directory

9:09:42 AM: /opt/build/repo/crwn-clothing

9:09:42 AM:

9:09:42 AM: ❯ Config file

9:09:42 AM: No config file was defined: using default values.

9:09:42 AM:

9:09:42 AM: ❯ Context

9:09:42 AM: production

9:09:42 AM:

9:09:42 AM: ────────────────────────────────────────────────────────────────

9:09:42 AM: 1. Build command from Netlify app

9:09:42 AM: ────────────────────────────────────────────────────────────────

9:09:42 AM:

9:09:42 AM: $ CI= npm run build

9:09:43 AM: > crwn-clothing@0.1.0 build

9:09:43 AM: > react-app-rewired build

9:09:44 AM: Creating an optimized production build…

9:09:49 AM: Failed to compile.

9:09:49 AM:

9:09:49 AM: Module not found: Error: Can’t resolve ‘source-map-resolve’ in ‘/opt/build/repo/crwn-clothing/src/utils/firebase’

9:09:49 AM:

9:09:49 AM: ────────────────────────────────────────────────────────────────

9:09:49 AM: “build.command” failed

9:09:49 AM: ────────────────────────────────────────────────────────────────

9:09:49 AM:

9:09:49 AM: Error message

9:09:49 AM: Command failed with exit code 1: CI= npm run build (https://ntl.fyi/exit-code-1)

9:09:49 AM:

9:09:49 AM: Error location

9:09:49 AM: In Build command from Netlify app:

9:09:49 AM: CI= npm run build

9:09:49 AM:

9:09:49 AM: Resolved config

9:09:49 AM: build:

9:09:49 AM: base: /opt/build/repo/crwn-clothing

9:09:49 AM: command: CI= npm run build

9:09:49 AM: commandOrigin: ui

9:09:49 AM: environment:

9:09:49 AM: - CI

9:09:49 AM: - REACT_APP_STRIPE_PUBLISHABLE_KEY

9:09:49 AM: - STRIPE_SECRET_KEY

9:09:49 AM: publish: /opt/build/repo/crwn-clothing/build

9:09:49 AM: publishOrigin: ui

9:09:49 AM: functionsDirectory: /opt/build/repo/crwn-clothing/netlify/functions

9:09:49 AM: Caching artifacts

9:09:49 AM: Started saving node modules

9:09:49 AM: Finished saving node modules

9:09:49 AM: Started saving build plugins

9:09:49 AM: Finished saving build plugins

9:09:49 AM: Started saving pip cache

9:09:49 AM: Finished saving pip cache

9:09:49 AM: Started saving emacs cask dependencies

9:09:49 AM: Finished saving emacs cask dependencies

9:09:49 AM: Started saving maven dependencies

9:09:49 AM: Finished saving maven dependencies

9:09:49 AM: Started saving boot dependencies

9:09:49 AM: Finished saving boot dependencies

9:09:49 AM: Started saving rust rustup cache

9:09:49 AM: Finished saving rust rustup cache

9:09:49 AM: Started saving go dependencies

9:09:49 AM: Finished saving go dependencies

9:09:51 AM: Build failed due to a user error: Build script returned non-zero exit code: 2

9:09:51 AM: Creating deploy upload records

9:09:51 AM: Failing build: Failed to build site

9:09:51 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)

9:09:51 AM: Finished processing build request in 39.153389298s

Hi @magedmohammed834, thanks for the feedback.

The quoted error above occurred because you are importing resolve from source-map-resolve package on line 22 in the file crwn-clothing/crwn-clothing/src/utils/firebase/firebase.utils.js

source-map-resolve package has not been installed.
Also note that source-map-resolve package has been deprecated.
More information in the link below about the deprecation.

Thanks.