Meris Tarhanis
05/16/2022, 2:51 PMimport { fileTypeFromBuffer } from 'file-type';
import AWS from 'aws-sdk';
When I try sending a request to any of those endpoints, I get this error message from lambda CloudWatch log:
2022-05-16T14:45:28.071Z undefined ERROR Uncaught Exception
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'node:fs'\nRequire stack:\n- /var/task/src/endpoints/files/create.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 'node:fs'",
"Require stack:",
"- /var/task/src/endpoints/files/create.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:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}
I suspect that Node's filesystem is not importing these packages correctly. Any suggestion on what might be the problem and/or how to fix it?Meris Tarhanis
05/16/2022, 2:56 PMnpx sst start
) works correctly.thdxr
05/16/2022, 3:20 PMthdxr
05/16/2022, 3:20 PMthdxr
05/16/2022, 3:43 PMMeris Tarhanis
05/16/2022, 3:44 PMMeris Tarhanis
05/16/2022, 3:47 PMMeris Tarhanis
05/16/2022, 3:49 PMError: The specified runtime is not supported for sst.Function. Only NodeJS, Python, Go, and .NET runtimes are currently supported.
thdxr
05/16/2022, 3:50 PMthdxr
05/16/2022, 3:50 PMnode:fs
in files/create.js
?Meris Tarhanis
05/16/2022, 3:51 PMMeris Tarhanis
05/16/2022, 3:51 PMthdxr
05/16/2022, 4:01 PMfile-type
library is using the new node imports so doing
import fs from "node:fs"
instead of
import fs from "fs"
thdxr
05/16/2022, 4:01 PMthdxr
05/16/2022, 4:03 PMTrey Overton
05/16/2022, 4:04 PMthdxr
05/16/2022, 4:05 PMMeris Tarhanis
05/16/2022, 4:06 PMMeris Tarhanis
05/16/2022, 4:43 PMapp.setDefaultFunctionProps({
runtime: "nodejs14.x",
});
Meris Tarhanis
05/16/2022, 4:44 PMthdxr
05/16/2022, 4:44 PM