helloworld
helloworld

Reputation: 195

Uncaught ReferenceError: Spark is not defined

I've been developing my Laravel app for some time now and decided to merge everything into Spark. I quickly realized my limited PHP/JS background was not really compatible with Spark so I tried to touch the Spark code as little as possible in order to keep things working and just use the goodies of Spark (stripe integration, user notifications etc etc.

Anyway, I think I broke it. I can open my page but can't get the drop down user menu. Chrome informs me about the following error:

Uncaught ReferenceError: Spark is not defined 
at Object.module.exports.el (app.js:24333) 
 at webpack_require (app.js:20) 
at Object. (app.js:18567) 
at webpack_require (app.js:20) 
at Object. (app.js:51833) 
at webpack_require (app.js:20) 
at app.js:66 at app.js:69

I am using a Ubuntu installation that I build using vagrant, everything seemed to work fine. Since I wanted to update to Laravel 5.5 anyway, I decided to checkout a new Spark project and integrate all my code. After some hurdles I got it to work, but again, the same error. It's probably something very trivial, so I apologize in advance ....

For sake of completedness, if I checkout a vanilla spark test app I can register and everything works perfect.

And after copying the relevant files, modifying composer.json (and running composer update etc). I get the same error again....

Anyone??

Upvotes: 1

Views: 706

Answers (1)

Zac Grierson
Zac Grierson

Reputation: 665

Make sure you include

<script>
    window.Spark = @json(array_merge(Spark::scriptVariables(), []));
</script>

In your <head></head>

Upvotes: 3

Related Questions