Cannot find module "laravel-echo"

I am studying the Laravel Echo Socket.js setup and after the article here

Code in bootstrap.js 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 do not use pusher and redis. On the link page above, I think there are no installation instructions given only for socket.io

Can someone explain if I missed something?

+6
source share
2 answers

I needed to install below packages.

 npm install -g laravel-echo-server 

then follow the step by step instructions here

Finally, put the code below any js file.

 <script src="http://{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script> 
+1
source

I solved the same problem by installing the following packages:

 npm install --save laravel-echo pusher-js 
0
source

Source: https://habr.com/ru/post/914606/


All Articles