Netlify build error: cannot find module (functions)

How would you approach this problem?

While deploying on Netlify, the build process repeatedly fails with the following error message:

“Build failed: Cannot find module ‘xyz-package’”

The package in question appears correctly in the pnpm-lock.json file, however I am not explicitly using such a package in my project, it may be a subdependency of another package but I don’t understand what that has to do with the error. This error is happening in netlify functions, functions/function.js.

I have tried removing both node_modules and pnpm-lock.json, uploaded the changes and still the error continues.

I add the configuration of my netlify.toml file:

[build.processing]
skip_processing = true

[build]
command = "pnpm run build"
functions = "functions"
publish = "dist"

How can this problem be solved?

Have you tried to add .npmrc with shamefully-hoist=true as its contents?