
So you'll have something like that
...
"version": "1.0.0",
"description": "",
"type": "module",
"main": "src/index.js",
...

ok I'll try that

Also you can change the second line to
const sdk = require("node-appwrite");
const { parseBuffer } = require("music-metadata");
But both solutions will do just fine

But according to music-metadata package:
The JavaScript in runtime is compliant with ECMAScript 2017 (ES8). Requires Node.js® version 6 or higher.

Yes I saw

is it still working?

Is this fixed the problem?

unfortunately , it doesnt work this is the new error I got:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/code-start/src/index.js
require() of ES modules is not supported.
require() of /usr/code-start/src/index.js from /usr/local/src/server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/code-start/package.json.

Yes, sorry You need also to change the first line Try change the first line to this and test and lmn
import sdk from "node-appwrite";
import { parseBuffer } from "music-metadata";

And I try this also this is the error I got:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/code-start/src/index.js
require() of ES modules is not supported.
require() of /usr/code-start/src/index.js from /usr/local/src/server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/code-start/package.json.

okok I'll try this one

Good

Yes, a bit confusing What I meant is if you change to this code
const sdk = require("node-appwrite");
const { parseBuffer } = require("music-metadata");
Then you need to remove the type:"module"

does not work

I think I am going to downgrade the pagkage

Have you try that? What error you got?

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/code-start/src/index.js
require() of ES modules is not supported.
require() of /usr/code-start/src/index.js from /usr/local/src/server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/code-start/package.json.

And you change all the require
to import
?

finally its work I just downgrade the package

anyways thank you for your time to assist me

god bless

ð

i want to use ES modules, i inserted type: module in package js, and changed all require to import statements, but still get the "Must use import to load ES" as above @Binyamin

Please create a new topic in https://discord.com/channels/564160730845151244/1072905050399191082 with you issue

[SOLVED] Type module in node js clound function
Recommended threads
- Appwrite CLI
I try to deploy a function using Appwrite CLI but it says: `appwrite functions createDeployment ^ --functionId=xyz^ --code="." ^ --activate error: u...
- Cloud Functions Executions partially dow...
Yesterday we reported a wide Function-Downtime. Today we have the same - just not wide-spread across all functions. DEV is down - Prod still working. Its the s...
- Appwrite Functions Generally Down?
We are getting customer support requests, that our service is down. We tried to pinpoint it, and we can't see any logs of any appwrite cloud function in the pas...
