Npm run build fails only on netlify with the error: The "from" argument must be of type string. Received undefined

The issue: I have a gatsby blog on netlify [happy-ardinghelli-804962.netlify.app → sukantamaikap.com]. I’m facing the below build failure only during build on netlify (on local [mac with exact same node version], it passes like a breeze)

9:12:12 PM: npm ERR! code ERR_INVALID_ARG_TYPE
9:12:12 PM: npm ERR! The "from" argument must be of type string. Received undefined
9:12:12 PM: npm ERR! A complete log of this run can be found in:
9:12:12 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-06-18T11_11_13_975Z-debug-0.log
9:12:12 PM: Error during NPM install
9:12:12 PM: Build was terminated: Build script returned non-zero exit code: 1

I tried the usual fix from StackOverflow without any help.

Here is my netlify.toml:

[build]
  publish = "public"
  command = "gatsby build"
[build.environment]
  NODE_VERSION = "16.15.1"

Build Log: Netlify App

Hey @smaikap

This issue is possibly due to node v16.15.1 as outlined in the Node v16.15.1 (npm v8.11.0) breaks some builds. Possibly changing this to v16.15.0 may prove successful.

Negative, moving to 16.15.0 does not help

Unfortunately, the error is with one of your dependencies than Netlify. You need to find which one. With a non-public repo, we cannot comment on that.

It started working once I moved the base image to Ubuntu Focal 20.04 from Ubuntu Xenial 16.04