首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未定义Require。Object.crypto object.url

未定义Require。Object.crypto object.url
EN

Stack Overflow用户
提问于 2021-08-20 22:43:24
回答 1查看 94关注 0票数 1

我正在尝试从react应用程序上传文件,安装aws-sdk后,出现以下错误:

代码语言:javascript
运行
复制
external "crypto":1 Uncaught ReferenceError: require is not defined
    at Object.crypto (external "crypto":1)
    at __webpack_require__ (bootstrap:19)
    at Object../node_modules/uuid/lib/rng.js (rng.js:4)
    at __webpack_require__ (bootstrap:19)
    at Object../node_modules/uuid/v4.js (v4.js:1)
    at __webpack_require__ (bootstrap:19)
    at Object../node_modules/short-uuid/index.js (index.js:7)
    at __webpack_require__ (bootstrap:19)
    at Object../node_modules/react-aws-s3/dist/react-aws-s3.js (react-aws-s3.js:1)
    at __webpack_require__ (bootstrap:19)

或者这个:

代码语言:javascript
运行
复制
external "url":1 Uncaught ReferenceError: require is not defined
    at Object.url (external "url":1)
    at __webpack_require__ (bootstrap:19)
    at Module../node_modules/@aws-sdk/credential-provider-imds/dist/es/fromContainerMetadata.js (index.bundle.js:6294)
    at __webpack_require__ (bootstrap:19)
    at Module../node_modules/@aws-sdk/credential-provider-imds/dist/es/index.js (index.bundle.js:6562)
    at __webpack_require__ (bootstrap:19)
    at Module../node_modules/@aws-sdk/credential-provider-node/dist/es/index.js (tslib.es6.js:239)
    at __webpack_require__ (bootstrap:19)
    at Module../node_modules/@aws-sdk/client-sts/dist/es/runtimeConfig.js (index.bundle.js:5351)
    at __webpack_require__ (bootstrap:19)

你有什么办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-21 06:49:20

通过将webpack的配置更改为

目标:'web',

src

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68868720

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档