Back

Cloud Function fails after upgrading to node-appwrite 12.1.0-rc.4 due to typescript

  • 0
  • Functions
  • Cloud
anmot.
14 May, 2024, 05:58

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/usr/local/server/src/function/node_modules/node-appwrite/dist/client' imported from /usr/local/server/src/function/node_modules/node-appwrite/dist/index.mjs

It worked fine when node-appwrite version was 9.0.0. This seems to be some typescript misconfiguration. I tried various combinations but none of them worked. Can someone please help identify what might be the issue? Thanks in advance.

TypeScript
{
    "compilerOptions": {
        "target": "ES2022",
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "moduleDetection": "force",
        "isolatedModules": true,
        "rootDir": "src",
        "resolveJsonModule": true,
        "sourceMap": true,
        "allowJs": true,
        "outDir": "dist",
        "noImplicitReturns": true,
        "noUnusedLocals": true,
        "experimentalDecorators": true,
        "strictPropertyInitialization": false,
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "noImplicitAny": true,
        "skipLibCheck": true,
        "esModuleInterop": true
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "dist"
    ]
}
TL;DR
Developers facing error after upgrading to node-appwrite 12.1.0-rc.4 due to typescript misconfiguration. The issue is with module paths. Update "moduleResolution" to "Node" and "module" to "CommonJS" in tsconfig.json.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more