Wolff Wolff - 9 months ago 94
Node.js Question

How I use node modules in laravel?

In my resource/assets/js I have tests.js ,I use gulp to build all files from js including this one ,in this file I have

var cmd = require('node-cmd');

'echo 3',
console.log('You are returning: ',data)

I want to use this module but not in root directory in public directory or in other directory than root,is any possibility to use require funcion for example from public folder using gulp?


Use Elixir to mix your JavaScript files in your assets folder into (1 app.js file in) your public folder.

Take a look at the documentation on Elixir and JavaScript

Note however, that both NodeJS and php are server side technologies and you should really know what you're doing to make them work together. Pushing NodeJS libraries in your public folder to use client side is NOT what NodeJS is made for and you should probably not use it that way.