ModuleParse失败或找不到
ModuleParse Failed or Not Found
我正在构建一个网络应用程序,允许用户通过Twilio API输入电话号码和发送短信。我已经在一个文件中构建了该功能,如下所示。如果我将cd
发送到此文件并运行node twilioActions.js
,则会发送文本消息。
var client = require('twilio')(CLIENT_ID, CLIENT_SECRET);
// ideally, I'd like to send the message using this method and call this from other JavaScript files
export const sendMessage = () => {
}
// the following code works when I run 'node twilioActions.js'
client.sendMessage({
to:'...',
from: '...',
body: 'Text message test.'
}, function(err, responseData) {
if (!err) {
console.log(responseData.from); // outputs "+14506667788"
console.log(responseData.body); // outputs "word to your mother."
}
});
但是,我想从不同的React文件中调用sendMessage
方法。给你:
import * as twilioActions from './twilioActions';
class PhoneView extends React.Component{
// other methods are hidden obviously, the one below is called when a button is pressed to send a message.
sendMessage() {
twilioActions.sendMessage();
}
}
当我试图构建项目时,我会得到以下错误:
ERROR in ./~/twilio/package.json
Module parse failed:/Users/Felix/Desktop/ECE590/node_modules/twilio/package.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
| "_args": [
| [
| "twilio",
@ ./~/twilio/lib/Client.js 5:17-43
ERROR in ./~/request/lib/har.js
Module not found: Error: Cannot resolve module 'fs' in /Users/Felix/Desktop/ECE590/node_modules/request/lib
@ ./~/request/lib/har.js 3:9-22
ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Cannot resolve module 'net' in /Users/Felix/Desktop/ECE590/node_modules/tunnel-agent
@ ./~/tunnel-agent/index.js 3:10-24
ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Cannot resolve module 'tls' in /Users/Felix/Desktop/ECE590/node_modules/tunnel-agent
@ ./~/tunnel-agent/index.js 4:10-24
我觉得我犯了一个简单的错误,可能没有使用正确的库或包含正确的参考文献。有人能为我指明正确的方向吗?非常感谢!
这里是Twilio开发人员的传道者。
twilio npm模块未构建或建议在前端使用。最重要的是,你需要在网站的前端代码中公开你的帐户凭据。这是一个安全风险,因为这意味着恶意攻击者可能会掌握你的凭据并滥用你的Twilio帐户。
我建议您在服务器端创建一个服务,您可以通过AJAX请求调用它来执行这样的操作。
相关文章:
- 气质的“nestRemoting()”有时可以'找不到关系
- 错误405:向Java控制器(Ajax)发送JSON时找不到POST方法
- 找不到模块捆绑包
- for循环中的javascript if语句找不到==
- 为什么JavaScript可以'找不到给定的InnerHTML并返回Cannot set property
- 失败:等待Protractor与页面同步时出错:“”;在窗口上找不到角度”;
- Babel编译错误:找不到模块核心js/library/fn/get迭代器
- [Vue warn]:找不到元素
- ngRoute找不到模板
- 未能加载,因为找不到支持的源.当播放HTML5音频元素时
- 因果报应-找不到模块:错误:无法解析模块'scs'
- Angular 2:在本地.json文件上找不到文件
- module.js在运行iron节点时找不到模块
- 放大弹出生成“;找不到文件”;YouTube视频的错误
- 我发现了一些只在移动设备上可见的垃圾邮件链接,我可以'找不到包含此垃圾邮件链接的脚本的位置
- 全局安装grunt失败,我可以'在npmjs.org上找不到
- ModuleParse失败或找不到
- Gulp.js安装失败,找不到模块'fetch.js'
- 为什么找不到匹配项时计数失败
- $grunt构建控制失败:找不到页面jit grunt