Issue: Getting following error while running inside Firebase Functions
Error [ERR_REQUIRE_ESM]: require() of ES Module ./node_modules/nanoid/index.js from ./cff/lib/utils/idGeneration.js not supported.
Instead change the require of index.js in ./cff/lib/utils/idGeneration.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (./cff/lib/utils/idGeneration.js:4:18) {
code: 'ERR_REQUIRE_ESM'
}
As error and docs describes you need to use ESM environment. We do not support CommonJS environment for 4.x and 5.x (there is 3.x branch still supported for legacy environments).
Issue: Getting following error while running inside Firebase Functions
Setup:
tsconfig.json
Code:
idGeneration.ts
Notes:
Temporary Fix:
Switching to the older version of nanoid (v3.3.7) does not throw this error.