Deploying server with @sendgrid/mail to aws ec2 server

184 views Asked by At

Anytime I try to run my contact server from aws ec2 it tells me the module cannot be found, even right after installing it with npm. It works fine on my local machine but I can't find any documentation on why this may be happening. I'd really appreciate the help.

Error: Cannot find module '@sendGrid/mail'
Require stack:
- /home/ec2-user/personalSite/api/contactServer.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:893:15)
    at Function.Module._load (internal/modules/cjs/loader.js:743:27)
    at Module.require (internal/modules/cjs/loader.js:965:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/ec2-user/personalSite/api/contactServer.js:5:18)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/ec2-user/personalSite/api/contactServer.js' ]
}
1

There are 1 answers

0
alexcaley On

Turns out modules cannot have capital letters, but as I am developing on a mac it handles the case with capital letters, whereas on aws running linux, it is still case sensitive. Simply changing my import to import "@sendgrid/mail" did the trick.