Node.js 进口;要求;将库导入到ReactJS项目中

Node.js 进口;要求;将库导入到ReactJS项目中,node.js,reactjs,npm,require,Node.js,Reactjs,Npm,Require,我正在学习ReactJS语言,现在我需要将request库添加到我的项目中。所以我通过npm install命令下载了这个库,现在我需要将这个库导入到我的项目中 但当我将使用: import Request from 'request'; 或 然后我无法构建我的应用程序(由于一些错误)。我不确定是否可以通过这种方式将第三方模块(或如何调用)导入ReactJS 你能帮我一点忙吗 ==包含错误===== 在我的.jsx文件中,我得到了: import React from 'react'; var

我正在学习ReactJS语言,现在我需要将request库添加到我的项目中。所以我通过
npm install
命令下载了这个库,现在我需要将这个库导入到我的项目中

但当我将使用:

import Request from 'request';

然后我无法构建我的应用程序(由于一些错误)。我不确定是否可以通过这种方式将第三方模块(或如何调用)导入ReactJS

你能帮我一点忙吗

==包含错误=====

在我的.jsx文件中,我得到了:

import React from 'react';
var request = require('request');
import {Table, TableBody, TableFooter, TableHeader, TableHeaderColumn, TableRow, TableRowColumn} from 'material-ui/Table';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import DialogWindow from '../components/DialogWindow.jsx'

import ContentAdd from 'material-ui/svg-icons/content/add';
import PlayArrow from 'material-ui/svg-icons/av/play-arrow';
import PlaylistAdd from 'material-ui/svg-icons/av/playlist-add';
如您所见,请求在第2行中导入。当我尝试构建我的应用程序时,会出现以下错误:

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in 'folder with project\node_modules\forever-agent'
 @ ./~/forever-agent/index.js 6:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in 'folder with project\node_modules\tough-cookie\lib'
 @ ./~/tough-cookie/lib/cookie.js 32:10-24
 @ ./~/request/lib/cookies.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in 'folder with project\node_modules\tunnel-agent'
 @ ./~/tunnel-agent/index.js 3:10-24
 @ ./~/request/lib/tunnel.js
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'folder with project\node_modules\forever-agent'
 @ ./~/forever-agent/index.js 7:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'folder with project\node_modules\tunnel-agent'
 @ ./~/tunnel-agent/index.js 4:10-24
 @ ./~/request/lib/tunnel.js
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in 'folder with project\node_modules\request\lib'
 @ ./~/request/lib/har.js 3:9-22
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

看起来是图书馆的一个已知问题。在(将
节点
配置对象添加到您的网页配置中)中介绍了修复程序,以使库在浏览器中工作


但是,你可能想考虑另一个库,比如OR../P>,你可以包括“一些错误”吗?你是在使用巴别塔或者其他东西来转换JS?@ Leand RoStuasARES,是的,我用简单的反应WebPACK Babel启动器KITI试过AXIOS,这个库工作得很好。谢谢你的推荐。

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in 'folder with project\node_modules\forever-agent'
 @ ./~/forever-agent/index.js 6:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in 'folder with project\node_modules\tough-cookie\lib'
 @ ./~/tough-cookie/lib/cookie.js 32:10-24
 @ ./~/request/lib/cookies.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in 'folder with project\node_modules\tunnel-agent'
 @ ./~/tunnel-agent/index.js 3:10-24
 @ ./~/request/lib/tunnel.js
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'folder with project\node_modules\forever-agent'
 @ ./~/forever-agent/index.js 7:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'folder with project\node_modules\tunnel-agent'
 @ ./~/tunnel-agent/index.js 4:10-24
 @ ./~/request/lib/tunnel.js
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx

ERROR in ./~/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in 'folder with project\node_modules\request\lib'
 @ ./~/request/lib/har.js 3:9-22
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./src/containers/Album.jsx
 @ ./src/routes.js
 @ ./src/index.jsx
 @ multi (webpack)-dev-server/client?http://127.0.0.1:8888 webpack/hot/dev-server react-hot-loader/patch ./src/index.jsx