# How to use 'net' Module in Code Node

**URL:** <https://community.n8n.io/t/how-to-use-net-module-in-code-node/33254>\
**Category:** Questions\
**Tags:** deployment, code\
**Created:** [November 22, 2023, 3:34am UTC](https://community.n8n.io/t/how-to-use-net-module-in-code-node/33254 "2023-11-22T03:34:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzrts](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jzrts](https://community.n8n.io/u/jzrts)\
**Post date:** [November 22, 2023, 3:34am UTC](https://community.n8n.io/t/how-to-use-net-module-in-code-node/33254/1 "2023-11-22T03:34:35Z")

</div>

## Describe the problem/error/question

In the Code node, const n = require(‘net’); throws an error, even though ‘net’ should be an allowed module by using -e NODE\_FUNCTION\_ALLOW\_EXTERNAL=net,ssh2,node,node:net (by using this config, ‘ssh2’ is available to the Code node, but ‘net’ and ‘node:net’ are not).

The Execute Command node is able to run nodejs and use net: nodejs -e “const n = require(‘net’); console.log(n);” outputs the expected contents of the net module. So net seems to be installed/available to node just not n8n.

But the Code node throws the error when trying do the same thing.

## What is the error message (if any)?

ERROR: Cannot find module ‘net’ [line 1]

## Please share your workflow

## Information on your n8n setup

- **n8n version:** 1.16
- **Database (default: SQLite):** Postgres
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):** Default
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** Docker
- **Operating system:** Ubuntu

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 23, 2023, 12:49pm UTC](https://community.n8n.io/t/how-to-use-net-module-in-code-node/33254/3 "2023-11-23T12:49:59Z")

</div>

Hi @jzrts, `net` is a built-in module provided by Node.js: [Net | Node.js v18.20.8 Documentation](https://nodejs.org/docs/latest-v18.x/api/net.html#net)

As such you’d need to allow its use through the `NODE_FUNCTION_ALLOW_BUILTIN` [environment variable](https://docs.n8n.io/hosting/environment-variables/environment-variables/#nodes). For example through a `docker run` command like this

```auto
docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n -e NODE_FUNCTION_ALLOW_BUILTIN=net n8nio/n8n:1.18.0

```

Afterwards you can use it in a workflow like so for example:

Result:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/4/b/4ba9f634126e373aa2cb66440a885cbc2eceef61.png)

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![jzrts](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jzrts](https://community.n8n.io/u/jzrts)\
**Post date:** [November 23, 2023, 3:55pm UTC](https://community.n8n.io/t/how-to-use-net-module-in-code-node/33254/4 "2023-11-23T15:55:45Z")

</div>

Thanks for the clarification! I didn’t realize it’s builtin.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [February 21, 2024, 3:56pm UTC](https://community.n8n.io/t/how-to-use-net-module-in-code-node/33254/5 "2024-02-21T15:56:13Z")

</div>

Closed on February 21, 2024, 3:56pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
