tristanrhodes
Explore posts from serversCDCloudflare Developers
•Created by tristanrhodes on 4/20/2024 in #workers-help
Do workers support dynamic module imports?
I'm trying to import modules dynamically. Is this supported with workers?
// Function to dynamically load database modules based on provider short names
async function loadDatabaseModule(shortName: string): Promise<IDatabaseOperations | null> {
try {
const module = await import(
./providers/${shortName.toLowerCase()}
);
return module.default as IDatabaseOperations;
Here is the error I get:
"logs": [
{
"message": [
"Failed to load module for d1:",
"Error: No such module "providers/d1"."
],
"level": "error",
"timestamp": 1713577569672
}1 replies
RRefine
•Created by flat-fuchsia on 6/5/2023 in #ask-any-question
"npm install" cannot find package.json
1) Used refine.new to download a bundled project
2) Unzipped the project file
3) From root of project, run "npm install"
4) NPM cannot find "package.json" (it doesn't exist)
8 replies