[英]Nuxt3 AWS-Amplify Error: 'request' is not exported by __vite-browser-external,
I am using AWS-amplify in my Nuxt3 for user authentication.我在我的Nuxt3中使用AWS-amplify进行用户身份验证。 The AWS-amplify uses @aws-sdk built-in and this is producing an error once I try to run build command.
AWS-amplify 使用内置的 @aws-sdk,一旦我尝试运行构建命令,就会产生错误。
Once this code is added to my plugin:将此代码添加到我的插件后:
import { Amplify } from 'aws-amplify';
Amplify.configure(config);
I try to build my project: npm run generate
and getting the following error我尝试构建我的项目:
npm run generate
并收到以下错误
'request' is not exported by __vite-browser-external, imported by node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js 'request' 不由 __vite-browser-external 导出,由 node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js 导入
I saw on GitHub for @aws-sdk this is a common error with vite.我在 GitHub 上看到 @aws-sdk 这是 vite 的常见错误。
Any suggestions or workaround for Nuxt ?对Nuxt 有什么建议或解决方法吗?
I solved my issue by pasting the following code inside the vite
object of the nuxt.config.ts .我通过将以下代码粘贴到
vite
的vite object 中解决了我的问题。
vite: {
define: {
"process.env.DEBUG": false,
"window.global": {},
},
resolve: {
alias: {
"./runtimeConfig": "./runtimeConfig.browser", //fix production build
},
},
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.