'Firebase functions failing to start with Nuxt3 ERR_REQUIRE_ESM

I am trying to run my nuxt3 application on the firebase emulator on my local machine, but its, however, failing with the following error

Error: Error occurred while parsing your function triggers.

Error [ERR_REQUIRE_ESM]: require() of ES Module <my_project_dir>.output\server\node_modules\node-fetch\src\index.js from <my_project_dir>.output\server\node_modules\firebase-functions\lib\common\providers\identity.js not supported. Instead change the require of index.js in C:\Users\Christian\vscode\nuxt3-starter.output\server\node_modules\firebase-functions\lib\common\providers\identity.js to a dynamic import() which is available in all CommonJS modules.

I am using the following command to build my application

npx cross-env NITRO_PRESET=firebase npm run build

My nuxt3 build version is v3.0.0-rc.1-27510703.46ecbc5 and my firebase library versions are

"firebase-admin": "^10.1.0", "firebase-functions": "^3.20.0", "firebase-functions-test": "^0.3.3"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source