Search code examples
aws-sdkaws-amplifyvitequasar

quasar vuejs amplify Error: 'request' is not exported by __vite-browser-external,


Purpose: Upload images from quasar project to aws amplify storage.

Installations : aws-amplify library for quasar and vuejs.

=> aws-amplify uses @aws-sdk for built in.

Once this code is added :

import { Amplify, Storage } from 'aws-amplify';

Amplify.configure(config);

I try to build my project: quasar -m build pwa/android/ios throws this error :

'request' is not exported by __vite-browser-external, imported by 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.

I'm using quasar 2.6.0, aws-amplify 4.3.35

Any suggestions or workaround ?


Solution

  • in quasar.config.js file, you can add below in build section :

    extendViteConf(viteConf, { isClient, isServer }) {
        Object.assign(viteConf.resolve.alias, {
          './runtimeConfig': './runtimeConfig.browser',
        });
      },