我的问题很容易解释。我已经用ViteJS初始化了一个React项目,然后为后端添加了aws放大。我开发了这个项目,一切都在运行npm的本地环境中工作。问题是我不能建造它。您可以在下面的文本中看到错误。你有什么想法吗?
‘请求’不是由__vite-浏览器-外部导出的,而是由node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js导入的。
发布于 2022-07-05 06:18:24
这类问题的根本原因似乎是aws-amplify
JS依赖于特定于Node的特性。有两种解决办法:
'xxxxx' is not exported by __vite-browser-external
这样的错误,将./runtimeConfig
的附加别名添加到vite.config.ts
文件中。所以它看起来就像:alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
'./runtimeConfig': './runtimeConfig.browser',
},
Uncaught ReferenceError: global is not defined
这样的错误,请在最顶层html文件(index.html
)中声明相应的全局变量。<script>
var global = global || window;
var Buffer = Buffer || [];
var process = process || {
env: { DEBUG: undefined },
version: []
};
</script>
github已经发行了一年多了:https://github.com/aws-amplify/amplify-js/issues/9639
https://stackoverflow.com/questions/70938763
复制相似问题