Describe the issue/error/question
I’m trying to import and use external modules in the code node. I have set the environment variable in my
docker-compose.yml file as
NODE_FUNCTION_ALLOW_EXTERNAL=ethers and added the path to the volumes so the module can be found by n8n just fine.
I have examined thoroughly posts like this and this, and tried creating a custom dockerfile using this post for guidance, but still I get an error.
What is the error message (if any)?
Information on your n8n setup
n8n version: 0.220.1
Database you’re using (default: SQLite): SQLite
Running n8n with the execution process [own(default), main]: main
Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker Compose
Ah looks like I missed that you made a post already, we can ignore the other one
So the error is saying that
ethers.util.id is undefined, it looks like ethers has loaded so the first part is ok. Are you sure you are using it correctly, I am not familiar with that package.
Hey Jon thanks for the reply! Well I kind of had the same thought was that maybe I was trying to use it incorrectly so I tried it using another library called
jsbarcode and still all methods returned the same error. It’s like it sees the library, but can’t access it still for some reason. The new dockerfile didn’t seem to help at all despite being able to require any external module I add.
I don’t think JS barcode would work as it looks to be designed for a browser rather than a backend service, Could that be the same for ethers?
Hmmm. Im not super versed on libraries really, but as far as I know I believe Ethers can be used in either a backend or as a script on the frontend using the CDN. According this import section of their docs, it can be used either way. Would that matter you think?
It looks like it would depend on what option you are using, Some of the docs mentions injecting into the window which wouldn’t be possible. What do you get if you use…
Still gives the same error actually:
It’s just strange that it even finds the
utils, but can’t find the specific method (I hope I’m saying that correctly).
I wonder if there is another way to use it, Without setting aside some time to build a custom image and learn how to use the package I am not sure what else to suggest.
Okay no worries I will play around with it and see if I can get it working. Just thought I would do a sanity test and ask to see if it was something obvious. Thanks for the help!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.