MODULE NOT FOUND Error when trying to deploy code on netlify using CLI and getting 'npm run build' not found issue when trying to deploy code using ui

I have tried to deploy my express project on netlify(doesn’t have any frontend). I have followed this tutorial - tutorial but I was facing an issue at the build time

6:10:44 PM: Netlify Build
6:10:44 PM: ────────────────────────────────────────────────────────────────
6:10:44 PM: ​
6:10:44 PM: ❯ Version
6:10:44 PM: @netlify/build 29.58.3
6:10:44 PM: ​
6:10:44 PM: ❯ Flags
6:10:44 PM: accountId: 678a602a81665b006edfb731
6:10:44 PM: baseRelDir: true
6:10:44 PM: buildId: 678ba1081da0899354e11f8a
6:10:44 PM: deployId: 678ba1081da0899354e11f8c
6:10:44 PM: ​
6:10:44 PM: ❯ Current directory
6:10:44 PM: /opt/build/repo
6:10:44 PM: ​
6:10:44 PM: ❯ Config file
6:10:44 PM: /opt/build/repo/netlify.toml
6:10:44 PM: ​
6:10:44 PM: ❯ Context
6:10:44 PM: production
6:10:44 PM: ​
6:10:44 PM: Build command from Netlify app
6:10:44 PM: ────────────────────────────────────────────────────────────────
6:10:44 PM: ​
6:10:44 PM: $ npm run build
6:10:44 PM: > backend@1.0.0 build
6:10:44 PM: > netlify deploy --prod
6:10:46 PM: Logging into your Netlify account…
6:10:46 PM: Opening netlify
response_type=ticket&ticket=f53aabbdce99ff481c3ce29c23383132
6:10:46 PM: - Waiting for authorization…
6:15:46 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for nocode changes)
6:15:46 PM: › Error: Timed out waiting for authorization. If you do not have a Netlify account, please create one at , then run netlify login again.
6:15:46 PM: ​
6:15:46 PM: “build.command” failed
6:15:46 PM: ────────────────────────────────────────────────────────────────
6:15:46 PM: ​
6:15:46 PM: Error message
6:15:46 PM: Command failed with exit code 1: npm run build (exit-code-1)
6:15:46 PM: ​
6:15:46 PM: Error location
6:15:46 PM: In Build command from Netlify app:
6:15:46 PM: npm run build
6:15:46 PM: ​
6:15:46 PM: Resolved config
6:15:46 PM: build:
6:15:46 PM: command: npm run build
6:15:46 PM: commandOrigin: ui
6:15:46 PM: publish: /opt/build/repo/dist
6:15:46 PM: publishOrigin: ui
6:15:46 PM: functionsDirectory: /opt/build/repo/functions
6:15:46 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:15:46 PM: Failing build: Failed to build site
6:15:47 PM: Finished processing build request in 5m43.296s

and when I tried to deploy using ‘npm un build’ command locally I was getting this error

❯ Context
:heavy_check_mark: Finished uploading blobs to deploy store
:heavy_check_mark: No cached functions were found
⠴ Hashing index.html › Warning:
{
“code”: “MODULE_NOT_FOUND”,
“requireStack”: [
“/Users/pinreddy/.nvm/versions/node/v20.17.0/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/zisi/resolve.js”
]
}

› Error: In file “/Users/pinreddy/Desktop/foodCourt/backend/functions/app.js”
Cannot find module ‘call-bound’
Require stack:

  • /Users/pinreddy/.nvm/versions/node/v20.17.0/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/zisi/resolve.js

can someone check on this I tried - fix but had no luck.

I am attaching my repo link - https://github.com/harshavardhanpinnapureddy/foodcourt/tree/backend_db

Hi @Harshavardhan, thanks for the post. I’m happy to help.
First, you are missing some modules based on the deploy logs you shared.

Kindly check your package.json again and then compare it to your build logs to find modules or packages that are not installed.

In addition to troubleshooting your code, you can find helpful support guides on troubleshooting builds at [Support Guide] Compiled Build and Deploy Resources – start here!

Thanks

I’d recommend running npm i -g npm again.

As far as deploying via Git, you should not be using Netlify CLI on Netlify builds.