DEV Community

Lumin
Lumin

Posted on

Vite build failed on project with aws-sdk

Vite work greate on local development.

But I got this error when build.

'request' is not exported by __vite-browser-external, imported by node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js
Enter fullscreen mode Exit fullscreen mode

The solution is put some script on index.html

<script>
var global = global || window
var Buffer = Buffer || []
var process = process || { env: { DEBUG: undefined }, version: [] }
</script>
Enter fullscreen mode Exit fullscreen mode

And that's it, all sorted! 😛

Thanks community.

Top comments (2)

Collapse
 
wesleycheek profile image
Wesley Cheek

Thanks, but unfortunately this didn't work for me but this fix did:

In vite.config.js add:

resolve: {
  alias: {
   './runtimeConfig': './runtimeConfig.browser',
  },
}

in define field

So my vite.config.js looks like this:

import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "./runtimeConfig": "./runtimeConfig.browser",
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});
Enter fullscreen mode Exit fullscreen mode
Collapse
 
aneeshahib profile image
Aneesha Jenson

Uncaught TypeError: t is not a constructor

Iam also facing this kind of issues when using aws-sdk with vite.js . Iam facing this above type of error.