0

I'm trying to use nanoid (https://www.npmjs.com/package/nanoid/v/2.1.2)

exports = async function(){
  const nanoid = require("nanoid");
  const uid = nanoid(10);
}

From within MongoDB realm runtime, but it throws:

uncaught promise rejection: failed to eval source for module 'nanoid': node_modules/nanoid/index.cjs: Line 9:7 Unexpected identifier (and 16 more errors)

And this is about all the error I can see from the Realm Dashboard.

What could be missing?

quarks
  • 33,478
  • 73
  • 290
  • 513

1 Answers1

0

The solution that worked for me:

  • Install a lower version nanoid
npm i nanoid@2.1.2

Then upload the package to MongoDB Realm functions through the dashboard.

quarks
  • 33,478
  • 73
  • 290
  • 513