# Netlify function cannot find module (w/ minimum code example)

**URL:** <https://answers.netlify.com/t/netlify-function-cannot-find-module-w-minimum-code-example/73122>\
**Category:** Support\
**Tags:** lambda-functions\
**Created:** [August 10, 2022, 12:50am UTC](https://answers.netlify.com/t/netlify-function-cannot-find-module-w-minimum-code-example/73122 "2022-08-10T00:50:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zipzapzanigan](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/zipzapzanigan/32/40123_2.png) [@zipzapzanigan](https://answers.netlify.com/u/zipzapzanigan)\
**Post date:** [August 10, 2022, 12:50am UTC](https://answers.netlify.com/t/netlify-function-cannot-find-module-w-minimum-code-example/73122/1 "2022-08-10T00:50:21Z")

</div>

I am running into a problem using lambda functions:

create a new netlify project, and create a single netlify function file /netlify/functions/ipfsTest.ts :

```auto
import { Handler } from "@netlify/functions";
import { create } from "ipfs-core"

const handler: Handler = async (event) => {
    const ipfs = await create();

    return {
        statusCode: 200,
        body: JSON.stringify({ message: ipfs.toString() }),
    };
};

export { handler };

```

Run `netlify functions:serve` and go to the URL for the function ipfsTest, and you may get

> Error - Cannot find module ‘./fetch.node’ Require stack: - /Users/zipzap/Dev/crypto/ipfsFunctionsTest/.netlify/functions-serve/ipfsTest/src/netlify/functions/ipfsTest.js - /Users/zipzap/Dev/crypto/ipfsFunctionsTest/.netlify/functions-serve/ipfsTest/ipfsTest.js - /Users/zipzap/.config/yarn/global/node\_modules/lambda-local/build/lambdalocal.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/lib/functions/runtimes/js/index.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/lib/functions/runtimes/index.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/lib/functions/registry.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/lib/functions/server.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/commands/dev/dev.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/commands/dev/index.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/commands/main.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/src/commands/index.js - /Users/zipzap/.config/yarn/global/node\_modules/netlify-cli/bin/run

I believe that the ‘./fetch.node’ is referring to the file ipfs-core/src/http/fetch.node.js, but for whatever reason, when it is run as a lambda function, it does not build or load the file properly.  
Here is the contents of my package.json:

```auto
{
  "name": "ipfsFunctionsTest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {},
  "dependencies": {
    "@netlify/functions": "^1.0.0",
    "ipfs-core": "^0.15.4"
  }
}

```

Anybody have any ideas?  
this happens both with the `ipfs-core` module, and the `ipfs-http-client` module.  
I have been trying to figure this out all day, and I am about to throw in the towel!

---

<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:** [August 12, 2022, 1:31pm UTC](https://answers.netlify.com/t/netlify-function-cannot-find-module-w-minimum-code-example/73122/2 "2022-08-12T13:31:00Z")

</div>

Hi @zipzapzanigan,

The solution here is to add the following to your `netlify.toml`:

```auto
[functions]
  external_node_modules = ["ipfs-utils"]

```

You can read more about it here:

> **[Modern, faster Netlify Functions: New bundler and JavaScript features](https://www.netlify.com/blog/2021/04/02/modern-faster-netlify-functions/#advanced-configuration)**
>
> We're improving Netlify Functions to give developers better and faster serverless workflows. Try out our function bundler and new JavaScript features.

We’ve opened an issue with the devs to log that better during the dev mode. However, if you had run `netlify build -offline`, you’d have found the solution too:

```auto
Packaging Functions from netlify/functions directory:
 - ipfsTest.ts
​
​
❯ The following Node.js modules use dynamic expressions to include files:
   - ipfs-utils
​
  Because files included with dynamic expressions aren't bundled with your serverless functions by default,
  this may result in an error when invoking a function. To resolve this error, you can mark these Node.js
  modules as external in the [functions] section of your `netlify.toml` configuration file:
​
  [functions]
    external_node_modules = ["ipfs-utils"]
​
  Visit https://ntl.fyi/dynamic-imports for more information.
​
​
(Functions bundling completed in 1.2s)

```

The CLI logs that to warn about it when “building” the production version. The issue that we’ve raised with the devs is to log this during the `dev` and `functions:serve` command too.
