Twilio + Nodejs 反应应用程序.找不到模块“net" [英] Twilio + Nodejs react app. Cannot find module "net"

查看:29
本文介绍了Twilio + Nodejs 反应应用程序.找不到模块“net"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 React 和 Express 创建一个 Web 应用程序,并使用 webpack-dev-server 进行开发.我想发送短信,但是当我尝试使用 Twilio 或 Plivo 时,我一直收到此错误 未捕获的错误:找不到模块net"

I'm trying to create a web app using React and Express and using webpack-dev-server for development. I want to send text messages but I keep getting this error when I try to use Twilio or Plivo Uncaught Error: Cannot find module "net"

我得到的另一个错误是:

Another error I get is:

./~/twilio/package.json
Module parse failed: /Users/H/github/app/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

我收到了更多类似的错误.我正在尝试遵循 Twilio 在文档中的示例,但仅通过在应用程序中要求 twilio,它就会给我这些错误.

And I get a lot more of errors similar to that one. I'm trying to follow the example Twilio has in the docs but just by requiring twilio in the app it gives me those errors.

推荐答案

根据错误信息你需要指定合适的用于 json 文件的加载器(它需要此处) 在你的 webpack-config 中.

According to error message you need specify appropriate loader for json files (it requires here) in your webpack-config.

{test: /\.json$/, loader: 'json'}

这篇关于Twilio + Nodejs 反应应用程序.找不到模块“net"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆