Parcel: Vue error

Created on 20 Sep 2018  路  6Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

I'm getting the following error:

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

(found in <Root>)

馃帥 Configuration (.babelrc, package.json, cli command)


package.json

  "scripts": {
    "watch": "parcel watch js/app.js --out-dir ../priv/static/js"
  },

馃 Expected Behavior

It should work

馃槸 Current Behavior

It doesn't work.
It returns the following error:

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
(found in <Root>)

馃拋 Possible Solution

馃敠 Context

馃捇 Code Sample

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | Latest |
| Node | Latest |
| npm/Yarn | Latest |
| Operating System | Windows 10 |

Bug Stale

Most helpful comment

Another option is to directly include the version with the template compiler in your code like this:

import Vue from 'vue/dist/vue.js';

However, you'll be getting the dev version in your build as well. So it's probably better to add this to your package.json

"alias": {
  "vue": "./node_modules/vue/dist/vue.common.js"
}

All 6 comments

Code samples would be helpfull as you鈥檙e probably doing something wrong or you鈥檙e running an outdated parcel

Sent with GitHawk

Hey, I have the same error, with:

| Software | Version |
|------------|---------|
| Parcel | 1.10.3 |
| Node | 8.10.0 |
| npm | 3.5.2 |
| babel-core | 6.26.3 |

Code samples:

index.html

<html>
    <head>
    </head>
    <body>
        <div id="app">
        </div>
        <script src='index.js'></script>
    </body>
</html>

index.js


import Vue from 'vue'
import App from './src/App.vue'

const vm = new Vue({
  el: '#app',
  template: '<App/>',
  components: { App },
})

src/App.vue

<template>
  <p>
    {{ message }}
  </p>
</template>

<script>
export default {
  data () {
    return {
      message: 'hello world'
    }
  }
}
</script>

I "solved" it, changing index.js to:

index.js

// import Vue from 'vue'
import Vue from 'vue/dist/vue.js'
import App from './src/App.vue'

const vm = new Vue({
    el: '#app',
    template: '<App/>',
    components: { App },
})

However, from the vue docs:

Do NOT do import Vue from 'vue/dist/vue.js' - since some tools or 3rd party libraries may import vue as well, this may cause the app to load both the runtime and standalone builds at the same time and lead to errors.

Is there any other workarounds?

Thanks!

@matngo @Sjoerrdd hi there, the runtime-only build requires a render functions to be given, your initial Vue instance has no render function instead you're defining a raw template.

I explained how to do it in #2178

@Hammster Thanks for the answer, it worked perfectly for me!

Another option is to directly include the version with the template compiler in your code like this:

import Vue from 'vue/dist/vue.js';

However, you'll be getting the dev version in your build as well. So it's probably better to add this to your package.json

"alias": {
  "vue": "./node_modules/vue/dist/vue.common.js"
}

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

Was this page helpful?
0 / 5 - 0 ratings