Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot build after configured alias vue to vue/dist/vue.esm-bundler.js #3220

Copy link
Copy link
Open
@tzfun

Description

@tzfun
Issue body actions
  • I confirm that this is an issue rather than a question.

Bug report

After I configured the alias, the build kept reporting errors:

config.js

function _resolve(dir) {
    return path.resolve(__dirname, '../../node_modules', dir)
}

export default defineUserConfig({

    ...

    bundler: viteBundler({
        viteOptions: {
            resolve: {
                alias: {
                    'vue': _resolve('vue/dist/vue.esm-bundler.js')
                }
            }
        }
    })

   ...

})

error stack:

[vite:load-fallback] Could not load E:/Project/<project_name>/doc-vuepress/node_modules/vue/dist/vue.esm-bundler.js/server-renderer (imported by node_modules/.pnpm/@vuepress+theme-default@2.0.0-rc.35_vuepress@2.0.0-rc.13/node_modules/@vuepress/theme-default/lib/client/layouts/NotFound.vue): ENOENT: no such file or directory, open 'E:\Project\<project_name>\doc-vuepress\node_modules\vue\dist\vue.esm-bundler.js\server-renderer'
    at async open (node:internal/fs/promises:641:25)
    at async Object.readFile (node:internal/fs/promises:1254:14)
    at async Object.load (file:///E:/Project/<project_name>/doc-vuepress/node_modules/.pnpm/vite@5.2.13/node_modules/vite/dist/node/chunks/dep-DEPSZ3SS.js:68377:33)
    at async PluginDriver.hookFirstAndGetPlugin (file:///E:/Project/<project_name>/doc-vuepress/node_modules/.pnpm/rollup@4.18.0/node_modules/rollup/dist/es/shared/node-entry.js:19674:28)
    at async file:///E:/Project/<project_name>/doc-vuepress/node_modules/.pnpm/rollup@4.18.0/node_modules/rollup/dist/es/shared/node-entry.js:18845:33
    at async Queue.work (file:///E:/Project/<project_name>/doc-vuepress/node_modules/.pnpm/rollup@4.18.0/node_modules/rollup/dist/es/shared/node-entry.js:19884:32)
ELIFECYCLE Command failed with exit code 1.

Steps to reproduce

What is expected?

Fix or provide a solution.

Other relevant information

My project needs to compile Vue code at runtime, so I need to use vue.esm-bundler.js instead of vue.runtime.esm-bundler.js, so Vue prompted me a warning: [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".

I configured the alias as prompted. When I start in the development environment (pnpm run docs:dev), everything is ok, but when I execute the package (pnpm run docs:build), the above error is reported.

When I remove this alias, the build runs ok, but I can't achieve the effect I want because Vue doesn't have runtime compilation turned on, and a warning is still prompted.

  • Output of npx vuepress info in my VuePress project:
  System:
    OS: Windows 10 10.0.19045
    CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
    Memory: 12.74 GB / 31.94 GB
  Binaries:
    Node: 22.2.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - D:\nodejs\node_global\yarn.CMD
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 7.20.0 - ~\AppData\Local\pnpm\pnpm.EXE
    bun: Not Found
  Utilities:
    Git: 2.27.0.
  Browsers:
    Chrome: 125.0.6422.142
    Edge: Chromium (125.0.2535.92)
  npmPackages:
    @vuepress/bundler-vite: ^2.0.0-rc.13 => 2.0.0-rc.13
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli: Not Found
    @vuepress/client: ^2.0.0-rc.2 => 2.0.0-rc.13
    @vuepress/core: Not Found
    @vuepress/markdown: Not Found
    @vuepress/shared: Not Found
    @vuepress/utils: 2.0.0-rc.2 => 2.0.0-rc.2
    vue: ^3.4.0 => 3.4.27
    vue-router: Not Found
    vuepress: ^2.0.0-rc.7 => 2.0.0-rc.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.