Skip to content

[Bug]: Failed to locate remote. #RUNTIME-004 #311

@dongnaebi

Description

@dongnaebi

Describe the bug

When I run npm run dev, everything works fine, but after building and running preview, I get the following error:

Uncaught (in promise) Error: [ Federation Runtime ]: Failed to locate remote. #RUNTIME-004
args: {"hostName":"host","requestId":"remote/App"}

Here is my configuration:

// host
export default defineConfig({
  plugins: [
    VueRouter({
      exclude: ['**/components/**', '**/composables/**'],
      extensions: ['.vue', '.tsx'],
    }),
    vue(),
    vueJsx(),
    tailwindcss(),
    vueDevTools(),
    federation({
      name: 'host',
      remotes: {
        remote: {
          type: 'module',
          name: 'remote',
          entry: '/legacy-app/remoteEntry.js',
          entryGlobalName: 'remote',
          shareScope: 'default',
        },
      },
    }),
    topLevelAwait(),
  ],
  build: {
    target: 'chrome75',
  },
  resolve: {
    alias: {
      '~': fileURLToPath(new URL('./src', import.meta.url)),
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    proxy: {
      '/legacy-app': {
        target: 'http://localhost:9888/',
        changeOrigin: true,
        rewrite(path) {
          return path.replace('/legacy-app', '')
        },
      },
    },
  },
})
federation({
        name: 'remote',
        filename: 'remoteEntry.js',
        exposes: {
          './App': './src/main.js'
        }
      })

what's wrong with me?

I found a similar issue: module-federation/core#3710

Version

v6.2.4

Reproduction

maybe later

Relevant log output

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions