NPM module dependencies are not found

I’m trying to build a production app for the first time on Netlify and am running into issues where it seems some modules I’m using are either not installing their dependencies or they’re somehow not in the right place. I am able to build it successfully locally using netlify-cli.

Here is the link to my most recent build: Netlify App

Here is the repo for my app: GitHub - JeffLuong/Jeffrey_Luong_Portfolio: Isomorphic personal portfolio website built in Preact.

Here is an example of one of these errors is. Any help will be appreciated!

4:21:10 PM: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
4:21:10 PM: ModuleBuildError: Module build failed (from ./node_modules/css-loader/dist/cjs.js):
4:21:10 PM: Error: Cannot find module './runtime/api'
4:21:10 PM:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
4:21:10 PM:     at Function.resolve (/opt/build/repo/node_modules/v8-compile-cache/v8-compile-cache.js:166:23)
4:21:10 PM:     at getImportCode (/opt/build/repo/node_modules/css-loader/dist/utils.js:232:78)
4:21:10 PM:     at process.then.result (/opt/build/repo/node_modules/css-loader/dist/index.js:132:49)
4:21:10 PM:     at runLoaders (/opt/build/repo/node_modules/webpack/lib/NormalModule.js:316:20)
4:21:10 PM:     at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:367:11
4:21:10 PM:     at /opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:233:18
4:21:10 PM:     at context.callback (/opt/build/repo/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
4:21:10 PM:     at process.then.catch.error (/opt/build/repo/node_modules/css-loader/dist/index.js:141:5)
4:21:10 PM:  @ ./src/index.js 2:0-23```

hey Jeff,

seems like we are falling back on some cached node modules:

1:20:26 PM: Started restoring cached node modules
1:20:26 PM: Finished restoring cached node modules

If you clear cache & deploy, do we get your dependencies correctly? :thinking:

Hi Perry,

Thanks for the quick response! I’ve been running the “Clear cache and deploy” option but it still runs into the same issue :sweat:

Is there something I’m missing or configuring incorrectly here?

Hey @JeffLuong, sorry to hear about your module woes. I went to take a look at your logs, but it looks like maybe you’ve deleted the site? Totally understandable, but if you wanna give it another shot, we’d be happy to try to debug with you. Alternatively, maybe this community query will be helpful if you keep digging solo:
https://answers.netlify.com/search?q=cannot%20find%20module%20webpack

Hi Jen,

Thanks for the tip! Yes I decided to use Heroku for deploying since I’ve already had an account with them and was more familiar with the setup. If / when I have the time again I’ll certainly try out Netlify in the future.

1 Like