
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
- A way to configure cloud function config...
Is there a way to configure cloud functions locally and keep that in github and deploy from source control instead of manually configuring it from the console f...
- Constant 404 Pages
Whenever I am navigating through items and pages to go through my collections and database I end up at a page that sends me a 404 error, if i refresh it remains...
- Cannot create a user
Hi, I am using a lowcoder frontend and trying to create a user in Appwrite (python function). Unfortunately, all I got is an error: "Raw body: Error". It means...
