I have been trying for the last 5 days to get a simple function to work. Not even the demo examples work and at this point, I think the issue is with DigitalOcean. I am using a Nodejs function to output a string. I try using import a module and this is the error I get: " Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘parse-domain’ imported from /tmp/index.mjs". So I try to change it to require and get this error: “ReferenceError: require is not defined in ES module scope, you can use import instead”. I am using “doctl serverless deploy . --remote-build” in the same directory as the project.yml. I added “type”: “module” in the package.json as well. I have the dependencies listed in there as well. I also ran npm install --package-lock-only parse-domain which didn’t work. I have module.exports.main = checkURL (function name) at the end. There is little to no documentation around DO functions and nodejs other than the examples which again doesn’t even work because I get the same error.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hey Bobby,
Thanks for responding! I did confirm doctl is up to date. The API token I’m using has both read and write permissions. Here is the repo I am using to test: https://github.com/SevenGuru/DO_Functions.
If you do come across something please let me know!
Nothing listed in the website, or even docs was not helpful. No matter what I do, I get the same error as the OP. I ended up switching to another platform.
This is the doc I referred to : https://docs.digitalocean.com/products/functions/reference/runtimes/node-js/#handle-native-dependencies
I too have been experiencing this issue with both Python and Node functions. I’m highly disappointed as I love DO products but functions seem to be a big fail on DO part right now.
I wish I could offer some solution but there’s literally no helpful documentation on this. It also took forever to figure out how to switch function namespaces and I’m still confused on how exactly it should be done. Super frustrating.