javascriptjquerynpmjquery-validatenode-modules

How to properly import jquery validation via npm


How do I properly import jquery validation via npm ?

(https://www.npmjs.com/package/jquery-validation). I tried to simply put: @import jquery-validation/dist/jquery.validate.min.js to my scripts but

I got some errors in my next scripts so I just downloaded the code and imported in this way:

<script src="{{ asset('js/jquery-validation.js') }}"></script>

I would, although, prefer the import from node_modules but I did not find any guide to do it properly.


Solution

  • Put

    const jquery-validation = require('jquery-validation');
    

    at the top of your app.js