aws-sdk error in expressjs project - Cannot find module 'aws-sdk/lib/config_service_placeholders

Viewed 2835

Everything worked fine then suddenly I got an error that crashes my app before start. I don't know from where error came when everything worked fine a day before

Error: Cannot find module 'aws-sdk/lib/config_service_placeholders'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (D:\projects\chatRush\controllers\userController.js:7:46)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (D:\projects\chatRush\routes\basicRoutes.js:6:24)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)```
2 Answers

I had the same problem and the solution was embarrassingly simple. I use Visual Studio Code and had accidentally imported a bad, unused file.

Going over your files mentioned in the error output and see if you have imported the wrong file :)

Hope you find it!

If no code changed, the problem is probably corrupted node modules. First step would be removing your node_modules and reinstalling them.

There could also be with a problem with the import statement in your userController.js line 7.

Related