Next.js Deploy Error: Cannot find module '../webpack-runtime.js'

Hey there, @nbouvrette :wave:

So glad to hear everything is working! :netliconfetti: Can you elaborate on your question: “are you integrated with the .env files that Next.js uses?” I want to make sure I fully understand what you are looking for.

Thanks!

Next.js support public environment variables which are stored in env files: Basic Features: Environment Variables | Next.js

The error I saw last night seemed to think that the environment variable was not defined when in fact it was. I had to explicitely define it on the app config in the Netlify web tool.

This step is not required in Vercel so I was wondering why.

I haven’t checked the details yet, but the possible cause would be that ENVs defined in Netlify UI are the only ones accessible to functions during the runtime, the ones in TOML or the env files won’t work.

Is that relevant here?

This would match what I saw - are you planning to support Next.js env file at some point? I do think its a good feature to support to avoid duplicating configurations

That might be something the plugin developers could take a look at. Would you be willing to file a feature request on the plugin’s repo? Happy to do it myself too.

However, I am not sure if this will be implemented. Netlify Functions have a plugin to get it done during the build time:

But functions by default don’t copy this. The plugin could possibly do it, but that would be for the developers to decide.

Done! Support Next.js Environment Variables · Issue #823 · netlify/next-runtime · GitHub

Thanks

Great, thanks for that. Devs will take a look at it soon.

I was facing same issue while i upgraded my nextjs app from 11 to 12. This is how i solved my problem -

Change the publish directory in the deploy settings to “.next” and updating the Essential Next Plugin from version 3 to version 4 as per the suggestion in the plugins tab of my site on netlify account.

1 Like

Thanks for coming back and sharing this! I am glad that the suggestion in the plugins tab helped you get on the right track!