laravel-elixir-browserify icon indicating copy to clipboard operation
laravel-elixir-browserify copied to clipboard

'import' and 'export' may appear only with 'sourceType: module' (6:0)

Open matthenning opened this issue 8 years ago • 10 comments

gulpfile.js:

var elixir = require('laravel-elixir');

require('laravel-elixir-vueify');

elixir(function(mix) {
    mix.browserify('vue.js');
});

vue.js:

var Vue = require('vue');

import CriticalState from './components/CriticalState.vue';

new Vue({

    el: '#dashboard',

    components: { CriticalState },

});

CriticalState.vue:

<template>
    {{ id }}
</template>

<script>
    export default {

        props: ['id']

    }
</script>

package.json

{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.0.0",
    "gulp": "^3.9.1",
    "laravel-elixir": "^5.0.0",
    "laravel-elixir-webpack-official": "^1.0.4",
    "vue": "^1.0.26",
    "vueify": "^8.7.0"
  },
  "dependencies": {
    "laravel-echo": "~1.0.0",
    "pusher-js": "~3.2.1",
    "laravel-elixir-browserify-official": "~0.1.3",
    "babel-preset-es2015": "~6.13.2",
    "babel-preset-react": "~6.11.1"
  }
}

versions:

npm -v
2.15.9
node -v
v4.5.0

When running gulp I get the following error: Error: Parsing file /.../resources/assets/js/components/CriticalState.vue: 'import' and 'export' may appear only with 'sourceType: module' (6:0)

Am I missing something?

matthenning avatar Aug 25 '16 08:08 matthenning

Having the same issue over here.

Spoowy avatar Aug 29 '16 10:08 Spoowy

What version of Laravel Elixir are you running?

JeffreyWay avatar Aug 29 '16 13:08 JeffreyWay

5.0

matthenning avatar Aug 29 '16 13:08 matthenning

Can you update your npm and Node dependencies to the latest release?

JeffreyWay avatar Aug 30 '16 21:08 JeffreyWay

Same problem here. I tried this in app.js: import addClass from 'vanillajs-browser-helpers/addClass';. Same error.

node: v6.9.5 [email protected] [email protected]

polikin avatar Oct 18 '17 14:10 polikin

Any news on this? Thanks.

goper-leo avatar Apr 19 '18 13:04 goper-leo

I had to redo my dev setup and I wasn't able to reproduce it after that.

matthenning avatar Apr 19 '18 15:04 matthenning

@matthenning Tell me please did manage to find any solution ? I just have a similar problem now. Thank you in advance for your response.

sergei-kh avatar Aug 20 '21 12:08 sergei-kh

I'm afraid I had to set up my dev environment from scratch and my issues disappeared. The problem was almost certainly somewhere on my end, but I could not identify it.

matthenning avatar Aug 20 '21 12:08 matthenning

@matthenning Got it, thanks

sergei-kh avatar Aug 20 '21 13:08 sergei-kh