【发布时间】:2016-03-01 22:21:03
【问题描述】:
问题
当我希望通过 Twilio 发送预先完成的 SMS 消息时,我在终端中收到与 require 方法相关的错误。我已经阅读了其他类似的 StackOverflow 问题,并尝试在我的脚本部分我的 index.html 中使用包含 RequireJS 的 CDN,或者 npm 安装 Browserify,但我不确定为什么我仍然收到错误。
错误
Uncaught Error: Module name "twilio" has not been loaded yet for context: _. Use require([])
scripts.js
// Twilio Credentials
var accountSid = 'AC7*********';
var authToken = '6b6*********';
// Require the Twilio module and create a REST client
var client = require('twilio')(accountSid, authToken);
client.messages.create({
to: "+16479933461",
from: "+12044002143",
body: "There is a new highest bidder. Visit {{websiteUrl}} to place another bid. All proceeds from the silent auction will go to the Samaritian House.",
mediaUrl: "http://farm2.static.flickr.com/1075/1404618563_3ed9a44a3a.jpg",
}, function(err, message) {
console.log(message.sid);
});
【问题讨论】:
标签: javascript node.js requirejs twilio browserify