DevDependency fails to install when using cache

Briefly summarize the issues you have been experiencing.

All builds (preview and from the selected branch) fail with an error:

Error: Cannot find module 'rollup-plugin-node-resolve'

This error only occurs when using the cached dependencies though. If I trigger a new build via the “Clear Cache and Deploy Site” button it will succeed.

Logs

Failed using cache
Succeeded without cache

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?

Found the note in the build-gotchas docs about not manually setting NODE_ENV=production, so removed that and got a build through. I’ve also tried updating my build environment to the latest one, but it only helped the first time (before there was a node_modules cache I assume).

I’m not sure why the cache is invalid, it almost seems like netlify is failing to properly cache the rollup-plugin-node-resolve module so when it uses the cache it’s just… missing. Is there a way to inspect the node_modules cache to verify?

Since I was capped on # of links, here’s the site I’m trying to deploy:

Hi,

How are you installing that dependency exactly? I don’t see it in your modular-css/package.json at main · tivac/modular-css · GitHub, though it is in a separate package.json in your repo: modular-css/package.json at main · tivac/modular-css · GitHub

Here’s my current build settings.

The dependency is installed by npm because of this line in the devDependencies.

Thanks. Is it installing that dev dependency in a separate directory other than your root node_modules? I ask because we only cache the single node_modules directory so any dependencies that live in other directories won’t be cached.

Yup, that explains it. I can bring all those dependencies up to the root but that’s pretty gnarly.

Could I instead change my “Build command” to run npm i before it tries to assembled the website?

The answer seems to be “yes I can”.

That’s… gross but workable I guess. Thanks for the help diagnosing this @futuregerald, I don’t think I ever noticed anything in the docs about the node_modules caching being only at the root so I likely would’ve never been able to track this down.