Back

upgrade old functions

  • 0
  • Self Hosted
S3ppo
4 Aug, 2024, 08:28

i tried to upgrade my old functions, but i now i get this error:

TypeScript
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/code-start/src/main.js
require() of ES modules is not supported.
require() of /usr/code-start/src/main.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 main.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/code-start/package.json.

    at new NodeError (node:internal/errors:363:5)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1125:13)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39)
    at require (node:internal/modules/cjs/helpers:93:18)
    at /usr/local/src/server.js:55:28
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

anybody knows what to do?

TL;DR
Developers are encountering an error when trying to upgrade old functions. The issue is related to ES modules and the error message suggests possible solutions such as renaming the file to end in .cjs, changing the requiring code to use import(), or removing "type": "module" from the package.json file.
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