Reputation: 838
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.
Upvotes: 0
Views: 7090
Reputation: 446
question is old but it my help someone. importing jquery-validation isn't enough for it to work. this is the full implementation :
import $ from "jquery";
import jqueryValidate from "jquery-validation";
window.$ = $; // u need to include jquery in your window
Upvotes: 0
Reputation: 160
I know this is old but importing it worked for me :
import jqueryValidate from "jquery-validation";
(don't forget to npm i jquery-validation
first of course)
Upvotes: 0
Reputation: 1158
Put
const jquery-validation = require('jquery-validation');
at the top of your app.js
Upvotes: 1