vuejs / vueify

Browserify transform for single-file Vue components
MIT License
1.17k stars 152 forks source link

Error: Parsing file: 'import' and 'export' may only appear at the top level #151

Open hirasso opened 8 years ago

hirasso commented 8 years ago

Hi there! I am just trying to get going with vueify. While re-producing your example given in the readme, I get this error:

Error: Parsing file: 'import' and 'export' may only appear at the top level

This is my app.vue file:


<style>
  .red {
    color: #f00;
  }
</style>

<template>
  <h1 class="red">{{msg}}</h1>
</template>

<script>

export default {
  data () {
    return {
      msg: 'Hello world!'
    }
  }
}

</script>

Any hint on what I am doing wrong?

anass2010 commented 7 years ago

make " module.exports = { " instead of " export default { "

maxvint commented 7 years ago

I've fixed by add { "presets": [ "es2015" ] } in the .bebelrc file.

dankuck commented 7 years ago

I was having this problem when I was using buble-loader. Attempted to use yuwenhui's solution on buble-loader instead, but it didn't work.

Using babel-loader with es2015 worked.

samlandfried commented 6 years ago

And for idiots like me, make sure you don't have any unclosed brackets 😅