loading...

Using external scripts with NuxtJS

granttransition profile image Grant Smith ・1 min read

I'm very new to Nuxt and I can't work out how to import other Javascript libraries.

For example, I am using Bulma in my project and find the BulmaJS library very useful as it saves me a lot of time. I appear not to be importing BulmaJs correctly into my project, but cannot figure out what I am missing?

After research, I have reached the following conclusions which may or may not be correct.

After installing npm install --save-dev @vizuaalog/bulmajs I have added the following code.

/plugins/navbar.js

import Navbar from '@vizuaalog/bulmajs/src/plugins/Navbar';
export default Navbar;

/nuxtconfig.js

plugins: [
 '@/plugins/navbar.js'
],

This results in a SyntaxError Unexpected identifier error?

I have found most other aspects of Nuxt very logical, but seem to be missing the point when it comes to using Javascript within projects. Another example was using Browser Update, I added this as a static file and used in my footer component, again a bunch of warnings.

What am I not understanding?

Discussion

pic
Editor guide