laravel-elixir-webpack-official icon indicating copy to clipboard operation
laravel-elixir-webpack-official copied to clipboard

Laravel Echo dies, when using gulp, because of missing pusher-js

Open jeffz2012 opened this issue 8 years ago • 0 comments

Laravel Echo dies, when using gulp, because of missing pusher-js. Even, if developer does not use pusher-js, but redis/socket duo, pusher-js must be installed.

I am talking about line#684 in laravel-echo\dist\echo.js window['Pusher'] = require('pusher-js');

In Laravel 5.3 docs it says: we will also install the pusher-js package since we will be using the Pusher broadcaster

in section with Pusher example, it also shows this npm install code: npm install --save laravel-echo pusher-js

So, anyone using pusher, has not problem, but people using redis/socket may have a problem as they may not bother to install pusher-js, since they do not intend to use it.

I think that either:

  • mentioned echo.js code should be changed to prevent error from surfacing,
  • or docs must clearly state, that pusher-js has to be installed via npm (even, if not used)
  • or maybe just adding it to dependencies list in package.json can help - that is if anyone bothers to run npm install

Anyway, it would be a good idea to fix this and save some people ulcers ;)

Aside from pusher: Remember folks to update to newest node.js, or you are going to get a lot of webpack errors.

Order of things ;) Put io client above app.js, e.g.:

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.2/socket.io.min.js"></script>
<script src="/js/app.js"></script>

or you are going to get undefined 'io'. Anyway, docs state that explicitly:

If you are going to pair the Redis broadcaster with a Socket.IO server, you will need to include the Socket.IO JavaScript client library in your application's head HTML element

Error thrown (if anyone cares to read):

[22:59:06] Using gulpfile U:\www\la5\gulpfile.js
[22:59:06] Starting 'all'...
[22:59:06] Starting 'sass'...
[22:59:08] Finished 'sass' after 2.03 s
[22:59:08] Starting 'webpack'...
{ [Error: ./~/laravel-echo/dist/echo.js
Module not found: Error: Can't resolve 'pusher-js' in 'U:\www\la5\node_modules\laravel-echo\dist'
resolve 'pusher-js' in 'U:\www\la5\node_modules\laravel-echo\dist'
  Parsed request is a module
  using description file: U:\www\la5\node_modules\laravel-echo\package.json (relative path: ./dist)

    Field 'browser' doesn't contain a valid alias configuration
  after using description file: U:\www\la5\node_modules\laravel-echo\package.json (relative path: ./dist)
    resolve as module
      U:\www\node_modules doesn't exist or is not a directory
      U:\node_modules doesn't exist or is not a directory
      U:\www\la5\node_modules\laravel-echo\dist\node_modules doesn't exist or is not a directory
      U:\www\la5\node_modules\node_modules doesn't exist or is not a directory
      U:\www\la5\node_modules\laravel-echo\node_modules doesn't exist or is not a directory
      looking for modules in U:\www\la5\node_modules
        using description file: U:\www\la5\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: U:\www\la5\package.json (relative path: ./node_modules)
          using description file: U:\www\la5\package.json (relative path: ./node_modules/pusher-js)

            as directory
              U:\www\la5\node_modules\pusher-js doesn't exist
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              U:\www\la5\node_modules\pusher-js doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              U:\www\la5\node_modules\pusher-js.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              U:\www\la5\node_modules\pusher-js.json doesn't exist
[U:\www\node_modules]
[U:\node_modules]
[U:\www\la5\node_modules\laravel-echo\dist\node_modules]
[U:\www\la5\node_modules\node_modules]
[U:\www\la5\node_modules\laravel-echo\node_modules]
[U:\www\la5\node_modules\pusher-js]
[U:\www\la5\node_modules\pusher-js]
[U:\www\la5\node_modules\pusher-js.js]
[U:\www\la5\node_modules\pusher-js.json]
 @ ./~/laravel-echo/dist/echo.js 684:35-55
 @ ./resources/assets/js/bootstrap.js
 @ ./resources/assets/js/app.js]
  message: './~/laravel-echo/dist/echo.js\nModule not found: Error: Can\'t resolve \'pusher-js\' in \'U:\\www\\la5\\node_modules\\laravel-echo\\dist\'\nresolve \'pusher-js\' in \'U:\\www\\la5\\node_modules\\laravel-echo\\dist\'\n  Parsed request is a module\n  using description file: U:\\www\\la5\\node_modules\\laravel-echo\\package.json (relative path: ./dist)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: U:\\www\\la5\\node_modules\\laravel-echo\\package.json (relative path: ./dist)\n    resolve as module\n      U:\\www\\node_modules doesn\'t exist or is not a directory\n      U:\\node_modules doesn\'t exist or is not a directory\n      U:\\www\\la5\\node_modules\\laravel-echo\\dist\\node_modules doesn\'t exist or is not a directory\n      U:\\www\\la5\\node_modules\\node_modules doesn\'t exist or is not a directory\n
U:\\www\\la5\\node_modules\\laravel-echo\\node_modules doesn\'t exist or is not a directory\n
looking for modules in U:\\www\\la5\\node_modules\n        using description file: U:\\www\\la5\\package.json (relative path: ./node_modules)\n          Field \'browser\' doesn\'t contain a valid alias configuration\n        after using description file: U:\\www\\la5\\package.json (relative path: ./node_modules)\n          using description file: U:\\www\\la5\\package.json (relative path: ./node_modules/pusher-js)\n            as directory\n              U:\\www\\la5\\node_modules\\pusher-js doesn\'t exist\n            no extension\n              Field \'browser\' doesn\'t contain a valid alias configuration\n              U:\\www\\la5\\node_modules\\pusher-js doesn\'t exist\n
    .js\n              Field \'browser\' doesn\'t contain a valid alias configuration\n
  U:\\www\\la5\\node_modules\\pusher-js.js doesn\'t exist\n            .json\n              Field \'browser\' doesn\'t contain a valid alias configuration\n              U:\\www\\la5\\node_modules\\pusher-js.json doesn\'t exist\n[U:\\www\\node_modules]\n[U:\\node_modules]\n[U:\\www\\la5\\node_modules\\laravel-echo\\dist\\node_modules]\n[U:\\www\\la5\\node_modules\\node_modules]\n[U:\\www\\la5\\node_modules\\laravel-echo\\node_modules]\n[U:\\www\\la5\\node_modules\\pusher-js]\n[U:\\www\\la5\\node_modules\\pusher-js]\n[U:\\www\\la5\\node_modules\\pusher-js.js]\n[U:\\www\\la5\\node_modules\\pusher-js.json]\n @ ./~/laravel-echo/dist/echo.js 684:35-55\n @ ./resources/assets/js/bootstrap.js\n @ ./resources/assets/js/app.js',
  showStack: false,
  showProperties: true,
  plugin: 'webpack-stream',
  __safety: { toString: [Function: bound ] } }

jeffz2012 avatar Jan 21 '17 22:01 jeffz2012