【发布时间】:2016-06-24 09:44:19
【问题描述】:
我正在尝试使用 sendrid 上的以下文档发送电子邮件:
https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/nodejs.html
我的 app.js 看起来像这样:
var sendgrid = require('sendgrid')('SENDGRID_APIKEY');
运行 npm start 时出现以下错误:
var sendgrid = require('sendgrid')(conf);
^
TypeError: require(...) is not a function
at Object.<anonymous> (C:\Users\Grandullon\Desktop\angular\app.js:8:36)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\Grandullon\Desktop\angular\bin\www:7:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
任何想法我做错了什么? conf 是我存储 API 密钥的变量。
我正在使用干净的快速安装。
谢谢
我的 package.json 可以按要求在这里查看:
【问题讨论】:
-
能给我们看看你的 package.json 文件吗?
-
是的,package.json 中不存在问题,我的错。看看 @Akash 的回答,这与导致问题的原因很相符。