Importing external module does not work no matter what

Hello!

I want to use external module named “mailparser” inside the “code node”. But I get the error ERROR: Cannot find module ‘mailparser’ [line 1] VMError. I am running n8n on npm. I installed npm using NVM. I installed the “mailparser” module in the $HOME/.nvm/versions/node/v18.14.0/lib/node_modules/n8n directory(using npm install mailparser --save) and globally(using npmm install -g mailparser). And then executed export NODE_FUNCTION_ALLOW_BUILTIN=* and export NODE_FUNCTION_ALLOW_EXTERNAL=*. Even then it is giving me the error. What should I do ?

I’m running n8n Version: 0.215.1 on npm.

Thanks.

Hey @Rusiru_Sadathana,

Welcome to the community :raised_hands:

I have just done a quick test on my local n8n instance and as we already use mailparser in my Code node just using the below works with no errors.

const mp = require('mailparser');
return $input.all();

I have NODE_FUNCTION_ALLOW_BUILTIN and NODE_FUNCTION_ALLOW_EXTERNAL both set to * could be worth checking that and maybe using Node v16 as well which is the officially supported version.

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