
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
- Corrupted files on AWS S3
Hello! I'm having trouble using S3 storage with appwrite for file uploads. It happens when uploading files from the Javascript SDK or from the console. The fi...
- Stuck in Readonly Mode After Pro Subscri...
Hello team, I really need some urgent help. I recently resubscribed to the Pro plan hoping to get back into a project I created a while ago, but I'm still unab...
- Missing C++ libstdc library in Python fu...
I have a function running Python 3.12 which suddenly started dumping errors (as of today; it worked yesterday). I hadn't changed any code so I found this odd, b...
