Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mniblett's avatar

browserify parse error on Vue file

I am struggling to register a custom Vue component in Spark 3.0 (just upgraded, but was having the same issue before):

C:\Users\Mike\code\StoryBuilder\resources\assets\js\components\Scene.vue:3
<template>
^
ParseError: Unexpected token

I am registering my vue like so in app.js

require('spark-bootstrap');
require('./components/bootstrap');

import Scene from './components/Scene.vue';
Vue.component('scene', Scene);

var app = new Vue({
    mixins: [require('spark')]
});

I tried: Vue.component('scene', require('./components/Scene.vue')); instead of importing the component originally with the same result.

I tried deleting my node modules directory and re-ran NPM install because I saw to do that in another thread, no luck.

I haven't changed the gulpfile from the default, the elixer function looks like this:

elixir(function(mix) {
    mix.less('app.less')
       .browserify('app.js', null, null, { paths: 'vendor/laravel/spark/resources/assets/js' })
       .copy('node_modules/sweetalert/dist/sweetalert.min.js', 'public/js/sweetalert.min.js')
       .copy('node_modules/sweetalert/dist/sweetalert.css', 'public/css/sweetalert.css');
});

my package.json looks like this:

{
  "private": true,
  "devDependencies": {
    "gulp": "^3.8.8"
  },
  "dependencies": {    
    "bootstrap": "^3.0.0",
    "jquery": "^2.1.4",
    "js-cookie": "^2.1.0",
    "laravel-elixir": "^6.0.0-11",
    "laravel-elixir-vue-2": "^0.2.0",
    "laravel-elixir-webpack-official": "^1.0.2",
    "moment": "^2.10.6",
    "promise": "^7.1.1",
    "sweetalert": "^1.1.3",
    "underscore": "^1.8.3",
    "urijs": "^1.17.0",
    "vue": "~2.0.1",
    "vue-resource": "~1.0.1"
  }
}

any ideas?

0 likes
3 replies
mniblett's avatar

Thanks @tomi I think laravel-elixir-vueify is equivalent to laravel-elixir-vue-2, but I'll try adding a require statement for the latter in my gulpfile when I get home tonight.

Spark seems to use all in-line templates and .js files in lieu of .vue files, so I guess that's why this didn't pop up as an error in the 3.0 or earlier codebase.

mniblett's avatar
mniblett
OP
Best Answer
Level 5

Ok, I think I see the problem, I guess my gulpfile is out of date, it should be using webpack instead of browserify.

(I thought I had copied it over from the vendor directory, but mine doesn't match what I see on github).

99% sure that's the problem.

confirmed, my gulpfile was an old version, copying it over from spark\install-subs resolved it.

Please or to participate in this conversation.