Build issue: ERR_INVALID_ARG_TYPE - The "from" argument must be of type string. Received undefined

I am running a NextJS application in a NPM workspace monorepo, and I am getting what appears to be a dependency issue. Installs work fine locally, but when I push to github to get a deploy preview working, I run into the following error.

Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
npm ERR! The "from" argument must be of type string. Received undefined
npm ERR! A complete log of this run can be found in: /opt/buildhome/.npm/_logs/2024-04-26T02_47_11_568Z-debug-0.log

When I add error log level i get the following stack trace, which doesnt give me much more to work with.

npm verb stack     at new NodeError (node:internal/errors:405:5)
npm verb stack     at validateString (node:internal/validators:162:11)
npm verb stack     at relative (node:path:1190:5)
npm verb stack     at /opt/buildhome/.nvm/versions/node/v18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1129:21
npm verb stack     at (<anonymous>)
npm verb stack     at /opt/buildhome/.nvm/versions/node/v18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1127:66
npm verb stack     at (<anonymous>)
npm verb stack     at [rollbackMoveBackRetiredUnchanged] (/opt/buildhome/.nvm/versions/node/v18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:1127:8)
npm verb stack     at [reifyPackages] (/opt/buildhome/.nvm/versions/node/v18.17.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:251:31)
npm verb stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Clearing cache and retriggering resolves the issue, but returns on new branches. I see others have had similiar issues and have tried all of the suggested remedies with no avail.

Hi @digioi,

Thanks for reaching out ! Sorry to hear about the issue.

Looking into the error, I do see some people have updated package lockfile and that resolved the issue. Not sure if that’s an option for you to try or if you’ve already tried it.

If you continue to have issues, could you provide us with a site name or a link to a deploy that failed?

I have tried a bunch of different things,

  • Rebuilding the package-lock
  • Thinking it was a peer-dep issue that was leaking in from the monorepo I did both the --legacy-peer-deps and --force on the npm install when building the package-lock.
  • setting CI=“” in the envVars
  • I have tried the set NPM_FLAGS=--version and update build to do a npm ci && npm run build

The deploy I am currently trying to get it working with 662b09cc3ba6530008d975d8

In the monorepo only one of the packages seems do be doing this.

When i manually clear the cache and retrigger, all new builds work on the deploy preview, but start again once i merge and branch off the base branch again

I realized I replied to myself, The Site I am currently having issues with is Netlify App

Do you happen to have a .npmrc in your repo? Maybe try removing that? The other option might not be well-received by you, but maybe you can try removing your dependencies one by one or in batches to narrow down the one that’s causing an issue? Sure your app would fail to build without the dependency, but at least npm i would work and you can work with a narrowed-down issue.

Or you could switch to a different package manager. Bun seems to work as a drop-in replacement for the most part.