Hi,
I’m playing around with functions and trying to do something simple but can’t seem to get it working. I’ve gotten two functions deployed, one works fine (simple “Hello, World”), now I’m trying to get a simple FaunaDB function working. I’ve created a database, gotten the key, and created the function. But, I’m getting an import failure right at the top:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'faunadb'\nRequire stack:\n- /var/task/faunatestreadall.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'faunadb'",
"Require stack:",
"- /var/task/faunatestreadall.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1156:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)",
" at Module.load (internal/modules/cjs/loader.js:1000:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:899:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)",
" at internal/main/run_main_module.js:18:47"
]
}
Maybe I’m being stupid, but I should just need to add the .js file in my functions directory like the Hello, World function, right? But, it looks like FaunaDB isn’t available on AWS at runtime. Do I need to do anything to include it? I didn’t think so, and none of the examples I’ve found seems to spell it out… or I’m just an idiot
Note that I haven’t posted the full function on purpose because at this point I don’t think it’s relevant, it’s dying on the first line, which is:
const faunadb = require("faunadb");
Anyone point me in the right direction? Thanks!