Error: Could not find “encoding” module in file, Netlify function

Thanks for reaching out and sharing this, @fivetwelve!

@fivetwelve

Can confirm too. Still exists. Had to install encoding dependency on root to get it working.

I also encountered this issue, but was able to solve it without installing any dependencies by using the new bundler (esbuild) available for netlify functions. Just added this to my netlify.toml, and everything worked:

[functions]
  node_bundler = "esbuild"
2 Likes

Thanks for sharing, @boyeborg! Glad everything is working for you :netliconfetti:

This worked for me! Thanks.

I was having a weird error where the functions will fail during preview builds, but work just fine in production builds.

@netlify, is this documented anywhere that the preview builds use different environment from the production build?

This thread is about 5 years old. Which environment are you talking about exactly?