Cannot find module 'mongodb-client-encryption'

Viewed 10842

I have a script.js file, there requires mongodb module, and when I want to run it with browser, it say that require is not defined.So, I installed browserify using npm, but when i want to use it browserify script.js -o all.js -d, I get an error:

Error: Cannot find module 'mongodb-client-encryption' from 'C:\Users\User\Desktop\browserify\node_modules\mongodb\lib\operations'

1 Answers

As per comment, you need to install mongodb-client-encryption module. This is a Node.JS wrapper for libmongocrypt.

npm install mongodb-client-encryption

If you're seeing an error message related to this module, i.e.:

TypeError: encryption.createDataKey is not a function

Check the module import line, it should be:

const mongodb = require('mongodb');
const { ClientEncryption } = require('mongodb-client-encryption');
const { MongoClient } = require('mongodb');

See also:

Related