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

[Error] cannot find vue/compiler-sfc when using yarn workspace and lerna to install node_modules. #2031

Closed
radiorz opened this issue Mar 15, 2023 · 1 comment

Comments

@radiorz
Copy link

radiorz commented Mar 15, 2023

depend:

"@vue/compiler-sfc": "^3.2.47",
"vue-loader": "^17.0.1",
 "webpack": "^5.76.1",

Try:

  • user lerna bootstrap to install node_modules,
  • and try to run
yarn workspace vue3 build

and came out error
image

fix:

just copy the vue/compiler-sfc in child project's node_modules to the root's node_modules and it works fine.

demo :

https://github.com/radiorz/webpack-demo

@heywhy
Copy link
Contributor

heywhy commented Apr 10, 2023

I'm also facing this same issue because my project does not need vue to work. while looking at the vue-loader project I found this

import { parse } from 'vue/compiler-sfc'

the above is an opposite of

export let compiler: typeof _compiler
try {
// Vue 3.2.13+ ships the SFC compiler directly under the `vue` package
// making it no longer necessary to have @vue/compiler-sfc separately installed.
compiler = require('vue/compiler-sfc')
} catch (e) {
try {
compiler = require('@vue/compiler-sfc')
} catch (e) {
throw new Error(
`@vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc ` +
`to be present in the dependency tree.`
)
}
}

replacingvue/sfc-compiler with ./compiler resolves this issue. I hope it get's fixed soon

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

2 participants