tprod's avatar
Level 2

Install and configure a pickadate package with Laravel Mix

Hi,

I'm stucked with the import of npm package here: https://www.npmjs.com/package/pickadate In this package there is CSS and JS but I don't know how can I exactly import them in my app.

I've done this :

window.pickadate = require('pickadate');

And try in my app.js to :

pickadate.('.datepicker').pickadate(); 

The error is :

$(...).pickadate is not a function

I don't want to bower again ;)

Thanks for your help

0 likes
6 replies
andreasbakir's avatar

first of all install the package

npm install pickadate --save
//or
yarn add pickdate

and than it should work!

tprod's avatar
Level 2

This what I did the directory exists in node_modules/pickadate. I think is the way I instantiate the module that I don't understand.

window.pickadate = require('pickadate'); works well but how can I do the instanciation of this module in js ?

Any ideas ?

topvillas's avatar
$(function() {
    $('.datepicker').pickadate(); 
});
tprod's avatar
Level 2

I used a lot Bower but this library get older. Same error $('.datepicker').pickadate(); outputs in console : function pickadate not found.

I don't put links in header for CSS and footer cause the package is in node_modules.

The mistake can be here. Is there a good tutorial in package installation through NPM in Laravel ?

tprod's avatar
Level 2

My problem is unfortunately unsolved :( Here is the code :

In app.js

$(document).ready(function() {

    // Init Datepicker
    $('.datepicker').pickadate();

});

In webpack I try to include the script like this

.js([
    'node_modules/pickadate/lib/picker.js',
    'node_modules/pickadate/lib/picker.date.js',
    'node_modules/pickadate/lib/picker.time.js',
    'resources/assets/js/app.js'
   ], 'public/js/app.js', './')

I think I'm going to retry Bower. I'm really stucked with webpack to include a jquery plugin. If someone knows ...

Please or to participate in this conversation.