xbrowsersync / api

Server-side REST API that serves requests from xBrowserSync client apps
GNU General Public License v3.0
796 stars 83 forks source link

node dist/api.js fails with "cannot find module bunyan" #81

Open AumCoin opened 2 years ago

AumCoin commented 2 years ago

Debian 11, fresh out of the box. I follow directions and and when I get to node dist/api.js it fails with the error below. The same is true whether I run as root or a normal user. I have tried various directions on the internet to install bunyan with --save or globally, but this did not affect the result. I have been through your directions multiple times. Please tell me how to resolve this error.

root@xbrowsersync:/home/rick/api# node dist/api.js
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'bunyan'
Require stack:
- /home/rick/api/dist/server.js
- /home/rick/api/dist/api.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/rick/api/dist/server.js:26:34)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/rick/api/dist/server.js', '/home/rick/api/dist/api.js' ]
}
AumCoin commented 2 years ago

Gave up in frustration after spending half a day on this and tried docker-compose by following the directions, then I installed the Firefox client. I click "switch service" and enter the hostname from my .env file. First I was using an IP address, then I switched the .env file to hostname and tried that in the client. In both cases it immediately tells me it cannot connect. I have no firewall enabled. I can ping the hostname from the docker host and elsewhere. Why isn't this hostname working with the Firefox client?

docker-compose ps:

      Name                     Command                  State                             Ports                       
----------------------------------------------------------------------------------------------------------------------
xbs-api             docker-entrypoint.sh node  ...   Up (healthy)   8080/tcp                                          
xbs-db              docker-entrypoint.sh mongod      Up             27017/tcp                                         
xbs-reverse-proxy   caddy reverse-proxy --from ...   Up             2019/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp

docker-compose top

xbs-api
UID    PID    PPID   C   STIME   TTY     TIME           CMD       
------------------------------------------------------------------
root   5562   5543   0   20:29   ?     00:00:01   node dist/api.js

xbs-db
  UID      PID    PPID   C   STIME   TTY     TIME                 CMD            
---------------------------------------------------------------------------------
systemd+   5464   5445   1   20:29   ?     00:00:03   mongod --auth --bind_ip_all

xbs-reverse-proxy
UID    PID    PPID   C   STIME   TTY     TIME                                CMD                           
-----------------------------------------------------------------------------------------------------------
root   5680   5661   0   20:29   ?     00:00:00   caddy reverse-proxy --from xbrowsersync.lan --to api:8080

It is not possible to connect to http://xbrowsersync.lan or https://xbrowsersync.lan from the client.

Not claiming to be an expert in any of the technologies used, just following the exact directions on your website for docker-compose, after the manual directions outright failed.

nero120 commented 2 years ago

You have a missing dependency (bunyan), could be for a myriad of reasons. Go read up on Node.js.

vdias commented 1 year ago

Same error even after install the module...

"npm install bunyan" finish without error... but still got the error.