vue-loader: incorrect peerDependencies for vue-template-compiler
The peer dependencies seems to be incorrectly define for the package vue-template comipler.
"peerDependencies": {
"css-loader": "*",
"vue-template-compiler": "^2.0.0"
},
"devDependencies": {
...
"vue": "^2.1.0",
"vue-template-compiler": "^2.1.0",
"webpack": "^2.1.0-beta.27"
}
This is causing following WARN on npm install.
julien:public article$ npm install
npm WARN vue-loader@10.0.2 requires a peer of vue-template-compiler@^2.0.0 but none was installed.
npm WARN chameleon@ No repository field.
npm WARN chameleon@ No license field.
julien:public article$
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 26 (5 by maintainers)
It took me about an hour to find this thread. Is it documented anywhere that one now needs to additionally install
vue-template-compilerin order to use this package?This is expected. npm3 doesn’t install peer dependencies for you. You need to explicitly install it yourself / list it in your package.json.
If you’d never use it directly, it doesn’t make sense to me to make it the user’s responsibility to handle this funky, unexplained under-the-hood module (needing to pin the version or whatever). I think there must be some better way to include
vue-template-compilerpackage underneath thevuepackage orvue-loaderpackage, because those two packages are all the user needs to care about. Just like for babel, you only need to installbabel-core, and if you use webpack, thenbabel-loaderas well. we all want to keep our dependency lists clean and light.Thanks for taking to time to respond to my comments. Let me know if I’m missing something or there’s more that I just don’t understand.
Edit: Would you ever use
vue-loaderwithout thevue-template-compiler? If so, then yeah you’re definitely right and I’m wrong. Otherwise, couldn’t you put them together in some way, or havevue-template-compilerlisted as a dependency instead of a peer dependency?I just upgrade to the same version and voilà
@yyx990803 I think this should be re opened and added to the documentation of vue-loader, this confused me getting started with vue also. Happy to add it if you like
The only reason we are doing this is because there’s simply no reliable way to pin a nested dependency, and pinning is a practical use case for some users.
Put it another way: making
vue-template-compilera nested dependency creates a problem that is much harder to solve for some users than having to install a peer dep. It’s not about theoretical dependency logic or purity, it’s a pragmatic tradeoff for minimal user frustration.why isn’t
vue-template-compilerautomatically included withvue-loader? Shouldn’t each dependency be a complete package, in that the developer would only install dependencies he understands and directly uses?I encountered a similar problem:
In my
package.json:After
npm i, When I runnpm start:My temporary solution:
You don’t use it directly. However, its version must be the same with
vueto ensure correct behavior. Making it a peer dep makes it possible to explicitly pin bothvueandvue-template-compilerto the same version.@timur-han you need to update
vue-template-compilerto matchvue’s version - 2.5.17Hi all, I’ve received the same warning:
vue-loader@10.3.0 requires a peer of vue-template-compiler@^2.0.0while having only
vue-loaderversion 10 installed as my dev-dependency. But still my project works fine in the browser, without errors etc.Webpack.config.js
From vue-template-compiler npm site
vue-template-compiler can be used to pre-compile Vue 2.0 templates into render functions to avoid runtime-compilation overhead and CSP restrictions. You will only need it if you are writing build tools with very specific needs. In most cases you should be using vue-loader or vueify instead, both of which use this package internally.
Error message:
[vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options.Fixed for me: Go to the line where this error was thrown (node_modules/vue-loader/lib/index.js line 21) and uncomment the try catch so you can get the real error. For me I had a version mismatch between vue-loader and vue-template-compiler. To fix this I ran npm update. However you may have to change some version numbers in package.json if this doesn’t fix the issue for you.
this is because of “vue” dependencies and “vue-template-compiler” had different suffix version, the suffix should be the same for example: if vue is
then vue-template compiler should be
hope this works for you