tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.65k stars 511 forks source link

Cannot find module '../dist/cli' - supervisord #592

Open bertalanimre opened 2 years ago

bertalanimre commented 2 years ago

Running laravel-echo-server inside supervisor results in the following error message

Error: Cannot find module '../dist/cli'
Require stack:
- /usr/bin/laravel-echo-server
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/bin/laravel-echo-server:10:28)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/bin/laravel-echo-server' ]
}

To Reproduce Steps to reproduce the behavior:

  1. Installed Node 12.18.3 via NVM
  2. Installed laravel-echo-server globally
  3. Created laravel-echo-server.json inside project folder
  4. Created supervisord ini file as follows:
    [program:echoserver]
    command=laravel-echo-server start --dir=/var/www/html/myproject/staging/configs
    directory=/var/www/html/mypropject/staging/configs
    autostart=true
    autorestart=true
    stopasgroup=true
    killasgroup=true
    user=web
    numprocs=1
    redirect_stderr=true
    stdout_logfile=/var/www/html/myproject/staging/shared/storage/logs/supervisor/echoserver.log
    logfile_maxbytes=50MB
    logfile_backups=31
  5. Started echo inside supervisorctl
  6. See log message

Additional context The module is present, but on a completely different place. It is: /home/web/.nvm/versions/node/v12.18.3/lib/node_modules/laravel-echo-server/dist/cli