通过 webtask.io 运行它:
var sgMail = require("@sendgrid/mail");
module.exports = function(context, req, res) {
res.writeHead(200, { 'Content-Type': 'text/html '});
res.end('<h1>Hello, world!</h1>');
};
此响应的结果:
{
"code": 400,
"message": "Compilation failed: Unexpected token {",
"error": "Unexpected token {",
"stack": "SyntaxError: Unexpected token {\n at
exports.runInThisContext (vm.js:53:16)\n at Module._compile
(module.js:373:25)\n at Module._compile
(/data/sandbox/lib/module.js:127:21)\n at
Object.Module._extensions..js (module.js:416:10)\n at Module.load
(module.js:343:32)\n at Function.Module._load
(module.js:300:12)\n at WebtaskModule.require
(/data/sandbox/lib/module.js:101:19)\n at require
(/data/sandbox/lib/module.js:136:21)\n at Object.<anonymous>
(/data/io/3bd979bebf074788b6849906721a8b06/webtask.js:2:14)\n at
WebtaskModule.compileWebtask (/data/sandbox/lib/module.js:95:34)"
}
如果我注释掉@sendgrid/mail
模块,一切运行正常。(而且,是的,我已将模块添加到 webtask 中。)
是我、模块还是 webtask?