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

**URL:** <https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259>\
**Category:** Support\
**Tags:** lambda-functions\
**Created:** [July 23, 2019, 2:40am UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259 "2019-07-23T02:40:42Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [May 27, 2021, 3:50pm UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259/21 "2021-05-27T15:50:16Z")

</div>

Thanks for reaching out and sharing this, @fivetwelve!

---

<div class="post-metadata">

**Author:** ![AndreasDeveloper](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/andreasdeveloper/32/30006_2.png) [@AndreasDeveloper](https://answers.netlify.com/u/AndreasDeveloper)\
**Post date:** [October 11, 2021, 6:59pm UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259/22 "2021-10-11T18:59:49Z")

</div>

@fivetwelve

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

---

<div class="post-metadata">

**Author:** ![boyeborg](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/boyeborg/32/30601_2.png) [@boyeborg](https://answers.netlify.com/u/boyeborg)\
**Post date:** [October 22, 2021, 6:35am UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259/23 "2021-10-22T06:35:28Z")

</div>

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](https://www.netlify.com/blog/2021/04/02/modern-faster-netlify-functions/). Just added this to my `netlify.toml`, and everything worked:

```auto
[functions]
  node_bundler = "esbuild"

```

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [October 22, 2021, 3:03pm UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259/24 "2021-10-22T15:03:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ntcho](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/ntcho/32/70745_2.png) [@ntcho](https://answers.netlify.com/u/ntcho)\
**Post date:** [February 11, 2026, 10:52pm UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259/25 "2026-02-11T22:52:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [February 17, 2026, 12:34pm UTC](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259/26 "2026-02-17T12:34:04Z")

</div>

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

[Previous page](https://answers.netlify.com/t/error-could-not-find-encoding-module-in-file-netlify-function/2259.md?page=1)
