Can't use cheerio inside code node

Describe the problem/error/question

I want to use this command inside the code node
const cheerio = require(‘cheerio’);
but it gives me error that cheerio isn’t found
I used
set NODE_FUNCTION_ALLOW_BUILTIN=* and defined cheerio && n8n start
and used the external parameter too but nothing worked

Information on your n8n setup

  • n8n version: 1.88
  • Running n8n via (Docker, npm, n8n cloud, desktop app): via npm on the global windows without docker or anything on command prompt
  • Operating system: windows 11

you can’t use additional library inside n8n code block, what are you trying to do, let me know if can help

Hi @soha_samy

The cheerio library is an external module, so setting NODE_FUNCTION_ALLOW_BUILTIN=* won’t enable its use in the Code node.

To use cheerio within the Code node, you need to install it first and then set the NODE_FUNCTION_ALLOW_EXTERNAL environment variable:

NODE_FUNCTION_ALLOW_EXTERNAL=cheerio
1 Like

I’m trying to clean the html content of a website from scripts and styles

I tried the external too and didn’t work and installed the cheerio by npm and npm list give me [email protected]

better make a node js script, you can easily get the clean html of a website from scripts and styles

It works for me, TY, I set in the truenas application setup