Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
tzfun opened this issue Jun 12, 2024 · 0 comments
Open
1 task done

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

tzfun opened this issue Jun 12, 2024 · 0 comments

Comments

@tzfun
Copy link

tzfun commented Jun 12, 2024

  • 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/@[email protected][email protected]/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/[email protected]/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/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:19674:28)
    at async file:///E:/Project/<project_name>/doc-vuepress/node_modules/.pnpm/[email protected]/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/[email protected]/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant