Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.02k stars 543 forks source link

Issue enabling MongoDB on fresh install in Ubuntu 20.04 #4772

Open astrugatch opened 1 year ago

astrugatch commented 1 year ago

Describe your issue Cannot enable MongoDB after installing MeshCentral on ubuntu 20.04

Server Software (please complete the following information):

Your config.json file

{
  "$schema": "http://info.meshcentral.com/downloads/meshcentral-config-schema.json",
  "__comment1__": "This is a simple configuration file, all values and sections that start with underscore (_) are ignored. Edit a section and remove the _ in front of the name. Refer to the user's guide for details.",
  "__comment2__": "See node_modules/meshcentral/sample-config-advanced.json for a more advanced example.",
  "settings": {
    "MongoDb": "mongodb://127.0.0.1:27017/meshcentral",
    "_cert": "myserver.mydomain.com",
    "WANonly": true,
    "_LANonly": true,
    "_sessionKey": "MyReallySecretPassword1",
    "_port": 443,
    "_aliasPort": 443,
    "_redirPort": 80,
    "_redirAliasPort": 80
  },
  "domains": {
    "": {
      "_title": "MyServer",
      "_title2": "Servername",
      "_minify": true,
      "_newAccounts": true,
      "_userNameIsEmail": true
    }
  },
  "_letsencrypt": {
    "__comment__": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before trying Let's Encrypt.",
    "email": "myemail@mydomain.com",
    "names": "myserver.mydomain.com",
    "production": false
  }
}

Doing a clean install of Mesh Central following the wiki here:https://meshcentral-community.com/doku.php?id=howto:installation:manual:ubuntu

At the point of enabling mongo db. Removed the _ from MongoDb and WANonly per the example. When trying to run node ./node_modules/meshcentral I get the following error:

Resetting main indexes...
Resetting server stats indexes...
ERR: /home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:92
            const validIndexOptions = Object.fromEntries(Object.entries({ ...userIndex }).filter(([optionName]) => VALID_INDEX_OPTIONS.has(optionName)));
                                             ^

TypeError: Object.fromEntries is not a function
    at CreateIndexesOperation.indexes.indexes.map.userIndex (/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:92:46)
    at Array.map (<anonymous>)
    at new CreateIndexesOperation (/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:88:32)
    at new CreateIndexOperation (/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:128:9)
    at Collection.createIndex (/home/meshadmin/node_modules/mongodb/lib/collection.js:258:78)
    at /home/meshadmin/node_modules/meshcentral/db.js:844:34
    at wrapper (/home/meshadmin/node_modules/mongodb/lib/utils.js:371:9)
    at session.endSession.endSessionError (/home/meshadmin/node_modules/mongodb/lib/operations/execute_operation.js:71:66)
    at wrapper (/home/meshadmin/node_modules/mongodb/lib/utils.js:371:9)
    at completeEndSession (/home/meshadmin/node_modules/mongodb/lib/sessions.js:154:17)
{ Error: Command failed: /usr/bin/node /home/meshadmin/node_modules/meshcentral --launch 1050
/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:92
            const validIndexOptions = Object.fromEntries(Object.entries({ ...userIndex }).filter(([optionName]) => VALID_INDEX_OPTIONS.has(optionName)));
                                             ^

TypeError: Object.fromEntries is not a function
    at CreateIndexesOperation.indexes.indexes.map.userIndex (/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:92:46)
    at Array.map (<anonymous>)
    at new CreateIndexesOperation (/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:88:32)
    at new CreateIndexOperation (/home/meshadmin/node_modules/mongodb/lib/operations/indexes.js:128:9)
    at Collection.createIndex (/home/meshadmin/node_modules/mongodb/lib/collection.js:258:78)
    at /home/meshadmin/node_modules/meshcentral/db.js:844:34
    at wrapper (/home/meshadmin/node_modules/mongodb/lib/utils.js:371:9)
    at session.endSession.endSessionError (/home/meshadmin/node_modules/mongodb/lib/operations/execute_operation.js:71:66)
    at wrapper (/home/meshadmin/node_modules/mongodb/lib/utils.js:371:9)
    at completeEndSession (/home/meshadmin/node_modules/mongodb/lib/sessions.js:154:17)

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:203:15)
    at maybeClose (internal/child_process.js:982:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:198:13)
    at Pipe._handle.close (net.js:607:12)
  killed: false,
  code: 1,
  signal: null,
  cmd:
   '/usr/bin/node /home/meshadmin/node_modules/meshcentral --launch 1050' }
ERROR: MeshCentral failed with critical error, check mesherrors.txt. Restarting in 5 seconds...
UFOTyler commented 1 year ago

Same issue on new install here as well... also running Ubuntu 20.04 LTS..

Levynger commented 1 year ago

SAme issue on Clean INstall, Unable to connect to local MongoDB. Same exact Error

rpppng commented 1 year ago

Same issue... How we can resolve this?

levyalon commented 1 year ago

eventually, i ended up using this script: https://github.com/techahold/Meshcentral-Installer

matt-pathr commented 1 year ago

I saw this on updating an existing installation to 1.1.0, Was there specific Fix?

matt-pathr commented 1 year ago

ok looks like maybe the mongo requirmnet changed and did not update. when I ran npm list shows as UNMET DEPENDENCY mongodb@4.1.0 npm ERR! missing: mongodb@4.1.0, required by meshcentral npm ERR! extraneous: debug@4.3.4 /opt/meshcentral/node_modules/acme-client/node_modules/debug npm ERR! extraneous: readable-stream@2.3.7 /opt/meshcentral/node_modules/archiver-utils/node_modules/readable-stream npm ERR! extraneous: readable-stream@2.3.7 /opt/meshcentral/node_modules/lazystream/node_modules/readable-stream npm ERR! extraneous: readable-stream@2.3.7 /opt/meshcentral/node_modules/compress-commons/node_modules/readable-stream npm ERR! extraneous: bytes@3.0.0 /opt/meshcentral/node_modules/compression/node_modules/bytes npm ERR! extraneous: depd@2.0.0 /opt/meshcentral/node_modules/cookies/node_modules/depd npm ERR! extraneous: safe-buffer@5.2.1 /opt/meshcentral/node_modules/content-disposition/node_modules/safe-buffer npm ERR! extraneous: safe-buffer@5.2.1 /opt/meshcentral/node_modules/express/node_modules/safe-buffer npm ERR! extraneous: ms@2.1.3 /opt/meshcentral/node_modules/send/node_modules/ms npm ERR! extraneous: archiver@5.3.1 /opt/meshcentral/node_modules/meshcentral/node_modules/archiver npm ERR! extraneous: safe-buffer@5.2.1 /opt/meshcentral/node_modules/multiparty/node_modules/safe-buffer

rajanJain1991 commented 1 year ago

@Ylianst Hi I am facing the same issue after updating meshcentral as my old version was not supporting letsencrypt. But now I have run into trouble with this and my machines are not showing anymore. I had tried to reinstall mongodb@4.12.1 looking at the errors. Not sure what went wrong.

github0004 commented 1 year ago

I was having the same issue and I fixed it by using another docker image. At the time I was using typhonragewind/meshcentral:mongodb and I tried a few others, and it had the same error. The docker container johann8/meshcentral is working for me and if anyone needs help on the config just reply.