gpt4 book ai didi

node.js - 找不到模块 'mongodb-client-encryption'

转载 作者:行者123 更新时间:2023-12-04 01:39:13 26 4
gpt4 key购买 nike

我有一个 script.js 文件,需要 mongodb模块,当我想用​​浏览器运行它时,它说require没有定义。所以,我安装了browserify使用 npm ,但是当我想使用它时browserify script.js -o all.js -d ,我得到一个错误:

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

最佳答案

根据评论,您需要安装 mongodb-client-encryption模块。这是 libmongocrypt 的 Node.JS 包装器.

npm install mongodb-client-encryption

如果您看到与此模块相关的错误消息,即:
TypeError: encryption.createDataKey is not a function

检查模块导入行,应该是:
const mongodb = require('mongodb');
const { ClientEncryption } = require('mongodb-client-encryption');
const { MongoClient } = require('mongodb');

也可以看看:
  • github.com/mongodb-labs/field-level-encryption-sandbox
  • MongoDB Node.JS: Client Side Encryption examples
  • 关于node.js - 找不到模块 'mongodb-client-encryption',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58258210/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com