DistDir issue when using next-on-netlify

When using next-on-netlify as shown here: Preview Mode for Next.js Now Fully Supported on Netlify - Learn More

I am getting an error about distDir. My next.config.js does not specify a value for distDir. Is there something I am missing?

2:13:43 PM: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
2:13:43 PM:     at validateString (internal/validators.js:120:11)
2:13:43 PM:     at join (path.js:1039:7)
2:13:43 PM:     at getNextDistDir (/opt/build/repo/node_modules/next-on-netlify/lib/helpers/getNextDistDir.js:8:10)
2:13:43 PM:     at Object.<anonymous> (/opt/build/repo/node_modules/next-on-netlify/lib/config.js:21:23)
2:13:43 PM:     at Module._compile (internal/modules/cjs/loader.js:1138:30)
2:13:43 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) 
2:13:43 PM:     at Module.load (internal/modules/cjs/loader.js:986:32)
2:13:43 PM:     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2:13:43 PM:     at Module.require (internal/modules/cjs/loader.js:1026:19) 
2:13:43 PM:     at require (internal/modules/cjs/helpers.js:72:18) {
2:13:43 PM:   code: 'ERR_INVALID_ARG_TYPE'
2:13:43 PM: }

Hey there, @qb3l :wave:

It looks like you got this fixed yesterday! :netliconfetti: If you are able to, would you mind sharing what change fixed this? This would be helpful for future Forums members who find themselves in a similar situation.

Hey @hillary!
I made it so we don’t use the next-on-netlify npm package but rather just use the netlify/plugin-nextjs package specified on the netlify.toml

This is basically what is recommended here: Announcing one-click install Next.js Build Plugin on Netlify | Netlify

I think Netlify’s docs and blog posts should be updated to link back to that page as the latest and easiest way of doing it now

I did end up losing the ability to connect to postgres for now though. Given we use the pg package to connect and that doesn’t work right now I had to add in my next.config.js some code to ignore pg-native in the webpack config

if (!dev) {
        config.plugins.push(new webpack.IgnorePlugin(/^pg-native$/))
1 Like

Thanks for sharing, @qb3l :slight_smile: I really appreciate you taking the time to write this out. It will definitely be beneficial should future Forums members encounter something similar.

Are you still experiencing this postgres issue? If so, let me know and I can get a member of the Support team to dig into that further.

1 Like

The problem is still there for postgres so any help would be greatly appreciated. Thanks @hillary!

Can you share your Netlify site name, your site ID, and your build log.Thank you! :netlisparkles:

Site: agitated-minsky-9b6ee0
Build log that failed: Netlify App

Hey there! Not my area of expertise but I don’t suppose this issue helps at all? Seems to relate to how the client is imported.

Hey @Scott !
That is basically the “solution” I put up in a comment above to fix the build but postgres is still broken when you try to use it. Presumably because something that is needed is not there or some other issue.

It’ll be a case of making sure that all appropriate dependencies are called up (pg, webpack etc. by the looks of things)! :slight_smile: