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.
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.
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… ethers.utils.parseEther("1.0")?
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!