Back

import { Client, ID ,Users} from 'node-appwrite'; ^^

  • 0
  • Functions
Shiba
14 Sep, 2023, 07:24

file:///usr/local/server/src/function/src/main.js:1 import { Client, ID ,Users} from 'node-appwrite'; ^^ SyntaxError: The requested module 'node-appwrite' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export. For example: import pkg from 'node-appwrite'; const { Client, ID ,Users} = pkg; at ModuleJob._instantiate (internal/modules/esm/module_job.js:98:21) at async ModuleJob.run (internal/modules/esm/module_job.js:137:5) at async Loader.import (internal/modules/esm/loader.js:162:24) at async execute (/usr/local/server/src/server.js:126:32) at async /usr/local/server/src/server.js:158:13

TL;DR
The user is getting a SyntaxError while trying to import modules from 'node-appwrite'. The error message suggests that the requested module is expected to be of type CommonJS, which does not support named exports. To fix this, the user should import the default export from 'node-appwrite' and then destructure the necessary variables. Example: import pkg from 'node-appwrite'; const { Client, ID, Users } = pkg;
Drake
15 Sep, 2023, 20:23

what version of appwrite are you on?

Drake
15 Sep, 2023, 20:23

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

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