iView not defined error while trying to import it

526 Views Asked by At

I'm trying to import iView UI on my VueJS project with Webpack inside main.js.

import iView from 'iview'

Then:

Vue.use(iView)

And console shows up an error saying

Uncaught ReferenceError: iView is not defined

I added iview plugin by doing npm i iview -D on my project.

Why this isn't working? Any ideas? Maybe some package.json issues? whenever i run npm run dev it compiles everything fine, no errors, no warnings.

1

There are 1 best solutions below

0
msqar On

Okay, after some hours of attempts, I found out I had two ways of including this lib.

By either doing: import iView from 'iview/dist/iview'

This one would throw a warning about types not defined for this, but if you do it like so:

const iView = require('iview')

It will work like a charm! Hope this helps to anyone who's under the same situation I was.