为了账号安全,请及时绑定邮箱和手机立即绑定

尝试导入 npm 时出错,进入 create-react-app

尝试导入 npm 时出错,进入 create-react-app

牛魔王的故事 2022-06-05 16:34:30
我正在尝试在 create-react-app 应用程序中导入 got ( https://www.npmjs.com/package/got ),而当我只是尝试将其导入一个文件时,甚至没有尝试执行任何代码应用程序无法编译,我收到以下错误:util.js:601 Uncaught TypeError: The "original" argument must be of type Function    at Object.promisify (util.js:601)    at Object.<anonymous> (get-body-size.js:7)    at Object../node_modules/got/dist/source/utils/get-body-size.js (get-body-size.js:30)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Object.<anonymous> (normalize-arguments.js:15)    at Object../node_modules/got/dist/source/normalize-arguments.js (normalize-arguments.js:441)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Object.<anonymous> (as-promise.js:8)    at Object../node_modules/got/dist/source/as-promise.js (as-promise.js:152)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Object../node_modules/got/dist/source/create.js (create.js:4)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Object../node_modules/got/dist/source/index.js (index.js:7)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Object../src/utils/ph_loader.js (ph_loader.js:1)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Module../src/components/Video.jsx (Searchbar.jsx:3)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Module../src/App.js (src sync:9)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Module../src/index.js (index.css?f3f6:45)    at __webpack_require__ (bootstrap:784)    at fn (bootstrap:150)    at Object.1 (ph_loader.js:21)    at __webpack_require__ (bootstrap:784)    at checkDeferredModules (bootstrap:45)    at Array.webpackJsonpCallback [as push] (bootstrap:32)    at main.chunk.js:1PS:我正在使用最新版本的 create-react-app 和最新版本的 got。
查看完整描述

1 回答

?
人到中年有点甜

TA贡献1895条经验 获得超7个赞

正如 gots 官方自述页面所说:

适用于 Node.js 的人性化且功能强大的 HTTP 请求库

所以它基本上只适用于服务器端的node js,你不能在前端使用。

相反,您可以使用像axios这样的库,它可以在前端 react 应用程序或后端 nodejs 应用程序中使用


查看完整回答
反对 回复 2022-06-05
  • 1 回答
  • 0 关注
  • 229 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号