Proper way to include 3rd daterangerpicker library in custom component

Hey everyone,

I’m hoping someone can point me in the right direction on how I would go about including a 3rd party npm library into a custom component. Using the daterangerpicker library for example:

1 - npm i daterangepicker ← Installs fine
2 - I am including it in my plugin/components/FilterTransactions.php as so:

public function onRun(){

Is this accurate to include it in this way, or is there somewhere else I should be doing a @import? Usually these libraries don’t require me to include separate libraries on top of them. In this case I needed to include daterangepicker/moment.min.js as well so I just want to make sure I’m not about to develop a terrible habbit!


Hey @theshado40

Referencing node_modules will be problematic since those files are technically not published. Consider installing Laravel Mix which has a copy() function to publish files from the directory. For example


Then copy it to your plugin’s asset directory.