每当我尝试从aws ec2运行联系人服务器时,它都会告诉找不到模块,即使在使用npm安装模块后也是如此。它在我的本地机器上运行良好,但我找不到任何关于为什么会发生这种情况的文档。我真的很感激你的帮助。
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' ]
}
原来模块不能有大写字母,但当我在mac上开发时,它用大写字母处理大小写,而在运行linux的aws上,它仍然区分大小写。简单地将我的导入更改为导入"@sendgrid/mail";成功了。