Cannot find module “laravel-echo”

自作多情 提交于 2020-05-29 03:11:48

问题


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?


回答1:


I solved the same problem installing the following packages:

npm install --save laravel-echo pusher-js 



回答2:


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>


来源:https://stackoverflow.com/questions/10394841/cannot-find-module-laravel-echo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!