Deployment to netlify fails during building

I’m trying to deploy a web app using parcel but it fails during buiilding process.
Here is the complete log of the process:
Initializing:
2:21:21 AM: build-image version: 1ae4e4d7d5e3544ab1eb7f270391cdbb47c1e1e5 (focal)

2:21:21 AM: buildbot version: 1ae4e4d7d5e3544ab1eb7f270391cdbb47c1e1e5

2:21:21 AM: Fetching cached dependencies

2:21:21 AM: Failed to fetch cache, continuing with build

2:21:21 AM: Starting to prepare the repo for build

2:21:21 AM: No cached dependencies found. Cloning fresh repo

2:21:21 AM: git clone --filter=blob:none GitHub - ali-ab-2003/Moshify-2-

2:21:22 AM: Preparing Git Reference refs/heads/main

2:21:23 AM: Starting to install dependencies

2:21:23 AM: Python version set to 3.8

2:21:24 AM: Attempting Ruby version 2.7.2, read from environment

2:21:24 AM: Using Ruby version 2.7.2

2:21:25 AM: Started restoring cached go cache

2:21:25 AM: Finished restoring cached go cache

2:21:25 AM: go version go1.19.10 linux/amd64

2:21:25 AM: Using PHP version 8.0

2:21:26 AM: v18.16.1 is already installed.

2:21:26 AM: Now using node v18.16.1 (npm v9.5.1)

2:21:26 AM: Enabling Node.js Corepack

2:21:27 AM: Started restoring cached build plugins

2:21:27 AM: Finished restoring cached build plugins

2:21:27 AM: Started restoring cached corepack dependencies

2:21:27 AM: Finished restoring cached corepack dependencies

2:21:27 AM: No npm workspaces detected

2:21:27 AM: Started restoring cached node modules

2:21:27 AM: Finished restoring cached node modules

2:21:27 AM: Installing npm packages using npm version 9.5.1

2:21:29 AM: npm WARN deprecated urix@0.1.0:

2:21:29 AM: npm WARN deprecated w3c-hr-time@1.0.2: Use your platform’s native performance.now() and performance.timeOrigin.
npm WARN deprecated source-map-url@0.4.1:

2:21:29 AM: npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN:

2:21:29 AM: npm WARN deprecated source-map-resolve@0.5.3:

2:21:29 AM: npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package

2:21:29 AM: npm WARN deprecated resolve-url@0.2.1
2:21:29 AM: 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.

2:21:30 AM: npm WARN deprecated request@2.88.2: request has been deprecated

2:21:30 AM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported

2:21:31 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies

2:21:31 AM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.

2:21:32 AM: npm WARN deprecated parcel-bundler@1.12.5: Parcel v1 is no longer maintained. Please migrate to v2, which is published under the ‘parcel’ package

2:21:32 AM: npm WARN deprecated core-js@2.6.12: core-js@<3.23.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. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

2:21:34 AM: added 813 packages, and audited 814 packages in 6s

2:21:34 AM: 75 packages are looking for funding

2:21:34 AM: run npm fund for details

2:21:34 AM: 30 vulnerabilities (16 moderate, 14 high)

2:21:34 AM: To address all issues, run:

2:21:34 AM: npm audit fix

2:21:34 AM: Run npm audit for details.

2:21:34 AM: npm packages installed

2:21:34 AM: Install dependencies script success

2:21:34 AM: Starting build script

2:21:35 AM: Detected 1 framework(s)

2:21:35 AM: parcel at version 1.12.5

2:21:35 AM: Section completed: initializing
Building:
2:21:38 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
2:21:36 AM: Netlify Build
2:21:36 AM: ────────────────────────────────────────────────────────────────
2:21:36 AM: ​
2:21:36 AM: ❯ Version
2:21:36 AM: @netlify/build 29.15.3
2:21:36 AM: ​
2:21:36 AM: ❯ Flags
2:21:36 AM: baseRelDir: true
2:21:36 AM: buildId: 64a881cf51fcd5144a4f2ef7
2:21:36 AM: deployId: 64a881cf51fcd5144a4f2ef9
2:21:36 AM: ​
2:21:36 AM: ❯ Current directory
2:21:36 AM: /opt/build/repo
2:21:36 AM: ​
2:21:36 AM: ❯ Config file
2:21:36 AM: No config file was defined: using default values.
2:21:36 AM: ​
2:21:36 AM: ❯ Context
2:21:36 AM: production
2:21:36 AM: ​
2:21:36 AM: Build command from Netlify app
2:21:36 AM: ────────────────────────────────────────────────────────────────
2:21:36 AM: ​
2:21:36 AM: $ npm parcel build index.html
2:21:37 AM: Unknown command: parcel
2:21:37 AM: To see a list of supported npm commands, run:
2:21:37 AM: npm help
2:21:37 AM: ​
2:21:37 AM: build.command failed
2:21:37 AM: ────────────────────────────────────────────────────────────────
2:21:37 AM: ​
2:21:37 AM: Error message
2:21:37 AM: Command failed with exit code 1: npm parcel build index.html (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
2:21:37 AM: ​
2:21:37 AM: Error location
2:21:37 AM: In Build command from Netlify app:
2:21:37 AM: npm parcel build index.html
2:21:37 AM: ​
2:21:37 AM: Resolved config
2:21:37 AM: build:
2:21:37 AM: command: npm parcel build index.html
2:21:37 AM: commandOrigin: ui
2:21:37 AM: environment:
2:21:37 AM: - CI
2:21:37 AM: publish: /opt/build/repo/dist
2:21:37 AM: publishOrigin: ui
2:21:38 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:21:38 AM: Failing build: Failed to build site
2:21:39 AM: Finished processing build request in 17.527s

I’m newbie learning web dev and this is my first time deploying a website so I kinda have no clue what is going wring here. Kindly help me out, I have tried pretty much every solution I saw on google.

Here is the screen shot of build settings as well:

@ali.abdullah.swl You have your Build command set to npm parcel build index.html which is almost certainly wrong.

If trying to call parcel directly you probably want parcel build index.html

If trying to execute the build script in your package.json you may want npm run build

You can try running your command locally before setting it on Netlify, if it doesn’t run on your computer it won’t run on Netlify.

i have and it works totally fine locally.

What is the contents of your package.json?

{
“name”: “moshify”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo "Error: no test specified" && exit 1”
},
“keywords”: ,
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“parcel-bundler”: “^2.0.0”
}
}

The only script that your package.json contains is:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
},

Which is the default one that is created when runing npm init

You have neither a parcel script, nor a build script.

I cannot see how npm parcel build index.html could possibly run fine.

Since npm itself doesn’t have a parcel command, it’s why you’re seeing exactly what I’d guess you would see:

2:21:36 AM: $ npm parcel build index.html
2:21:37 AM: Unknown command: parcel
2:21:37 AM: To see a list of supported npm commands, run:
2:21:37 AM: npm help

You could test this by running npm parcel locally.

Are you sure you’re not running parcel build index.html locally?