Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using node modules in Laravel

I am trying to include this module: https://www.npmjs.com/package/react-datepicker-component with react into my Laravel Framework.

I went on to using npm to install it but I am getting no where after that.

I could use some direction. Has anyone tried using NPM for Laravel other than for Laravel Elixir?

like image 837
Anraiki Avatar asked Aug 16 '15 03:08

Anraiki


1 Answers

I was stuck with this same issue for about an hour trying to pull in the inputmask node package.

The only way I was able to get it included was by attaching it to the window object in app.js (similar to what bootstrap.js does)

window.InputMask = require('inputmask');

If you don't want to load it every time (as it would with app.js) you can create a separate js file that contains only the line of code above and load that on select pages. I feel like there has to be a better way, but this is the only way I've found to make it work.

like image 105
coderp Avatar answered Oct 21 '22 05:10

coderp