Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module "laravel-echo"

Tags:

laravel-5.5

I am learning to configure Laravel Echo Socket.js and following an article here

Code in bootstrap.js is below

import Echo from "laravel-echo"

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001'
});

When I run the above code, it says, Cannot find module "laravel-echo"

I am not using pusher and redis. In the above reference page, I think, there is no installation guidelines given for only socket.io

Can somebody explain if I am missing anything?

like image 457
Pankaj Avatar asked May 01 '12 07:05

Pankaj


2 Answers

I solved the same problem installing the following packages:

npm install --save laravel-echo pusher-js 
like image 98
pableiros Avatar answered Oct 10 '22 23:10

pableiros


I needed to install below packages.

npm install -g laravel-echo-server

then following the step by step instruction as give here

Finally put below code before any js file.

<script src="http://{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
like image 32
Pankaj Avatar answered Oct 11 '22 01:10

Pankaj