Skip to content
Advertisement

Issues with importing Vuelidate Library

As a part of implementing Form Validation, I want to use Vuelidate library in a Sails.js page. The page gets the Vue code by using this webpage.page.js:

JavaScript

, which is linked to this webpage.ejs View Template:

JavaScript

This gives an error ‘Cannot use import statement outside a module’. I have the Vuelidate npm package installed. Thus, how can I import the Vuelidate library to get this working?

Advertisement

Answer

If you are using the Sails web template, you need to import Vuelidate dist files validators.min.js and vuelidate.min.js into the assets/dependencies folder. After that, Grunt imports the files and you’ll be able to use them globally without import because they will be available in the browser.

Check the documentation section The browser-ready bundle is also provided in the package.:

https://vuelidate.js.org/#sub-basic-usage

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement