Module not found: Can't resolve 'aws4'
Asked Answered
I

2

6

My project have two folder

  1. client
  2. server

both client and server runs but sometime on client when i visit any page so on the terminal the following errors shows how can fix these errors

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
Inclement answered 1/8, 2021 at 12:31 Comment(0)
F
3

I had the same exact problem with mongodb, unfortunatly it warn for modules that are not strictly required. An easy and quick solution to your problem, in your next.config file ignore these warnings:

module.exports = {
  webpack: (config) => {
    config.resolve.fallback = {
      "mongodb-client-encryption": false ,
      "aws4": false
    };

    return config;
  }
Forum answered 30/1, 2023 at 19:49 Comment(1)
this saved my b... , thank you. it's weird that this happens.Cavort
T
2

I got the same error too. All I did was run the below command (which installs the aws4 module) and all was solved.

npm install aws4
Threescore answered 22/2 at 7:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.