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)

Commits related to this issue

Most upvoted comments

It took me about an hour to find this thread. Is it documented anywhere that one now needs to additionally install vue-template-compiler in 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-compiler package underneath the vue package or vue-loader package, because those two packages are all the user needs to care about. Just like for babel, you only need to install babel-core, and if you use webpack, then babel-loader as 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-loader without the vue-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 have vue-template-compiler listed as a dependency instead of a peer dependency?

I just upgrade to the same version and voilà

 "vue": "^2.5.17",
 "vue-template-compiler": "^2.5.17",

@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-compiler a 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-compiler automatically included with vue-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 :

"devDependencies": {
   "vue-loader": "^10.0.2"
},
"dependencies": {
    "vue": "^2.1.8"
}

After npm i, When I run npm start:

ERROR in Cannot find module 'vue-template-compiler'
 @ ./src/routers/teamRouteConfig.js 35:22-58

My temporary solution:

npm i vue-template-compiler --save-dev

You don’t use it directly. However, its version must be the same with vue to ensure correct behavior. Making it a peer dep makes it possible to explicitly pin both vue and vue-template-compiler to the same version.

@timur-han you need to update vue-template-compiler to match vue’s version - 2.5.17

Hi all, I’ve received the same warning: vue-loader@10.3.0 requires a peer of vue-template-compiler@^2.0.0

while having only vue-loader version 10 installed as my dev-dependency. But still my project works fine in the browser, without errors etc.

Webpack.config.js

module: {
    rules: [
      {
        test: /\.vue$/,
        use: 'vue-loader'
      }

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

vue": "^2.5.21"

then vue-template compiler should be

"vue-template-compiler": "^2.5.21"

hope this works for you @ivanrusli is correct.

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

vue": "^2.5.21"

then vue-template compiler should be

"vue-template-compiler": "^2.5.21"

hope this works for you