Upgrading to node 22, or 18, results login scripts failing with “unexpected end of file”.
Based on this problem solution I need node 1.2.3, however that is not available in the node 22 runtimes.
What do you suggest?
Stated problem solution:
After Upgrading the Action Runtime to Node18, Getting Error "unexpected end of file" on Login
Version included in runtime.
Can I require? - Search which node modules you can use in webtask.io
Hi @esumerfield
Thank you for reaching out to us!
After you upgrade the Action to Node 22, can you please add the axios dependency on the latest version as axios@latest
and test if that results in the same error message? This should automatically select the latest version which should offer the best compatibility settings for the Node version.
Let me know if this worked for you!
Have a great one,
Gerald
1 Like
Tested three scenarios.
- Use @latest, though perhaps you were not being literal:
const axios = require("axios@latest")
"details": {
"error": {
"message": "Cannot find module 'axios@latest'\nRequire stack:\n- /data/io/node22/adff15f1-c739-4960-a0ad-b3904fb050ef/webtask.js"
}
},
- Tried the actual latest version 1.9.1
const axios = require("axios@1.9.1")
"details": {
"error": {
"message": "Cannot find module 'axios@1.9.1'\nRequire stack:\n- /data/io/node22/2d204225-3d07-45c4-9c08-0b537e88d446/webtask.js"
}
},
- Tried the latest supported axios version 1.2.1
const axios = require("axios@1.2.1")
"details": {
"error": {
"message": "unexpected end of file"
}
},
I must be doing something wrong.
Hi @esumerfield
Thank you for reaching back!
I have to apologise as I was not very clear with my indications, please allow me to try and provide more precise details. Before you add the const axios
in your Action, axios will need to be added as a dependency as described in the following documentation here. When you have the code line opened for an Action, you will find a couple of icons/options to the left of the input box, which should be Test, Secrets, Dependencies and Rules.
Here is also a screenshot of the icons, from within an Action, with axios installed on the latest version :
Once the correct dependency ( in your case axios ) and it’s version ( latest ) has been added, it can then be called within the code as you have attempted. I have also found this documentation which further outlines how to add dependencies, either from the Auth0 dashboard or from the Auth0 Management API with the Create an action endpoint. Please do notice that in this second documentations, dependencies are referred to as Modules, but it references the same functionality.
Please let me know if you were able to get everything running correctly this time and do excuse any confusion that came from my end. Looking forward to your input!
Best regards,
Gerald
This is good for actions. How can I do this for custom database scripts.