我的项目有两个文件夹
客户端和服务器都会运行,但有时当我访问任何页面时在客户端上运行,因此在终端上以下错误显示如何修复这些错误
wait - compiling...
warn -
../server/node_modules/mongodb/lib/core/auth/mongodb_aws.js
Module not found: Can't resolve 'aws4' in 'C:\Users\MyName\Desktop\Project\server\node_modules\mongodb\lib\core\auth'
../server/node_modules/mongodb/lib/operations/connect.js
Module not found: Can't resolve 'mongodb-client-encryption' in 'C:\Users\MyName\Desktop\Project\server\node_modules\mongodb\lib\operations'
../server/node_modules/mongoose/lib/index.js
Critical dependency: the request of a dependency is an expression
../server/node_modules/require_optional/index.js
Critical dependency: the request of a dependency is an expression
../server/node_modules/require_optional/index.js
Critical dependency: the request of a dependency is an expression
../server/node_modules/require_optional/index.js
Critical dependency: the request of a dependency is an expression
我在 mongodb 上也遇到了同样的问题,不幸的是它会警告不严格需要的模块。 简单快速地解决您的问题,在您的 next.config 文件中忽略这些警告:
module.exports = {
webpack: (config) => {
config.resolve.fallback = {
"mongodb-client-encryption": false ,
"aws4": false
};
return config;
}
我也遇到了同样的错误。我所做的就是运行以下命令(安装 aws4 模块),一切都得到了解决。
npm install aws4