Cannot start NodebB: "Cannot find module ./undefined"



  • Hello,

    I cannot start NodeBB using the following Dockerfile. I have a weird error that I never saw in the forum or GitHub:

    [...]
    Schema update complete!
    
    2020-05-25T08:29:29.588Z [4567/92] - error: Cannot find module './undefined'
    Require stack:
    - /nodebb/src/database/index.js
    - /nodebb/src/start.js
    - /nodebb/require-main.js
    - /nodebb/app.js {"code":"MODULE_NOT_FOUND","requireStack":["/nodebb/src/database/index.js","/nodebb/src/start.js","/nodebb/require-main.js","/nodebb/app.js"]}
    [cluster] Child Process (92) has exited (code: 0, signal: null)
    
    

    Dockerfile
    Note: I tried also cloning the main GitHub repo, same error.

    FROM node:lts as build
    
    SHELL ["/bin/bash", "-c"]
    
    ENV NODE_ENV=production \
        daemon=false \
        silent=false
    
    WORKDIR /nodebb
    
    RUN echo \
     && echo "[*] Installing build dependencies" \
     && apt-get update && apt-get install -y \
        git \
        curl \
        wget \
        unzip
    
    RUN echo \
     && echo "[*] Cloning NodeBB" \
     && wget https://github.com/NodeBB/NodeBB/archive/v1.13.3.zip \
     && unzip v1.* \
     && find ./NodeBB-* -maxdepth 1 -mindepth 1 -exec mv -t . {} + \
     && cp install/package.json package.json
    
    RUN echo \
     && echo "[*] Installing NodeBB dependencies" \
     && npm install --only=prod \
     && npm cache clean --force
    
    COPY rootfs/nodebb/config.json /nodebb/config.json
    
    VOLUME /nodebb/public/uploads /etc/nodebb /var/lib/redis
    
    EXPOSE 4567
    
    CMD node ./nodebb build ; node ./nodebb start ; echo ; echo "ERROR, opening bash for debug" ; bash
    

    config.json

    {
      "url": "http://sub.domain.tld",
      "secret": "random-password-9_aHYo9eczr3WO8vSTItJH",
      "database": "redis",
      "redis": {
        "host": "nodebb-redis",
        "port": "6379",
        "password": "",
        "database": "0"
      },
      "port": "4567",
      "bcrypt_rounds": "21",
      "upload_path": "/public/uploads",
      "jobDisabled": "false",
      "bind_address": "0.0.0.0",
      "isCluster": "false",
      "session_store": "redis",
      "logFile": "logs/output.log"
    }
    

    Start Redis and NodeBB

    docker run --name nodebb-redis -d --rm redis
    docker build -t my/nodebb:debian .
    docker run --name nodebb -ti --rm -p 4567:4567 my/nodebb:debian
    

    Once started, I connect inside the docker container to debug.
    The following commands are running with success:

    node ./nodebb build
    node ./nodebb upgrade
    

    But impossible to start nodebb using either:

    node ./nodebb start
    node app.js
    node loader.js
    
    NodeBB v1.13.3 Copyright (C) 2013-2014 NodeBB Inc.
    This program comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute it under certain conditions.
    For the full license, please visit: http://www.gnu.org/copyleft/gpl.html
    
    Clustering enabled: Spinning up 1 process(es).
    
    2020-05-25T09:26:16.897Z [4567/425] - info: Initializing NodeBB v1.13.3 http://leclos.lmilcent.com
    2020-05-25T09:26:18.331Z [4567/425] - error: Error: Cannot find module './undefined'
    Require stack:
    - /nodebb/src/database/index.js
    - /nodebb/src/start.js
    - /nodebb/require-main.js
    - /nodebb/app.js
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
        at Function.Module._load (internal/modules/cjs/loader.js:840:27)
        at Module.require (internal/modules/cjs/loader.js:1019:19)
        at require (internal/modules/cjs/helpers.js:77:18)
        at Object.primaryDB.initSessionStore (/nodebb/src/database/index.js:27:20)
        at Object.start.start (/nodebb/src/start.js:33:12)
    [cluster] Child Process (425) has exited (code: 0, signal: null)
    
    


  • Problem solved, for the record I have added all file on my GitHub: https://github.com/LM1LC3N7/Dockerfiles/blob/master/nodebb/README.md



  • I tried also to start from the official Dockerfile with some edit, another error (EADDRINUSE).

    Dockerfile

    FROM node:lts
    
    WORKDIR /nodebb
    
    ENV NODE_ENV=production
    
    RUN apt-get update && apt-get install git -y
    
    RUN git clone https://github.com/NodeBB/NodeBB /nodebb \
     && cp install/package.json /nodebb/package.json
    
    RUN npm install --only=prod && \
        npm cache clean --force
    
    ENV NODE_ENV=production \
        daemon=false \
        silent=false
    
    EXPOSE 4567
    
    CMD node ./nodebb build ;  node ./nodebb start
    

    Error after the web configuration

    2020-05-25T09:02:27.704Z [4567/154] - info: Initializing NodeBB v1.13.3 http://sub.domain.tld
    2020-05-25T09:02:29.383Z [4567/154] - info: [socket.io] Restricting access to origin: http://sub.domain.tld:*
    2020-05-25T09:02:29.723Z [4567/154] - info: Routes added
    2020-05-25T09:02:29.725Z [4567/154] - info: NodeBB Ready
    2020-05-25T09:02:29.728Z [4567/154] - info: Enabling 'trust proxy'
    2020-05-25T09:02:29.730Z [4567/154] - error: NodeBB address in use, exiting...listen EADDRINUSE: address already in use 0.0.0.0:4567 {"code":"EADDRINUSE","errno":"EADDRINUSE","syscall":"listen","address":"0.0.0.0","port":4567,"stack":"Error: listen EADDRINUSE: address already in use 0.0.0.0:4567\n    at Server.setupListenHandle [as _listen2] (net.js:1313:16)\n    at listenInCluster (net.js:1361:12)\n    at doListen (net.js:1500:7)\n    at processTicksAndRejections (internal/process/task_queues.js:85:21)"}
    2020-05-25T09:02:29.732Z [4567/154] - error: uncaughtException: listen EADDRINUSE: address already in use 0.0.0.0:4567
    Error: listen EADDRINUSE: address already in use 0.0.0.0:4567
        at Server.setupListenHandle [as _listen2] (net.js:1313:16)
        at listenInCluster (net.js:1361:12)
        at doListen (net.js:1500:7)
        at processTicksAndRejections (internal/process/task_queues.js:85:21) {"error":{"code":"EADDRINUSE","errno":"EADDRINUSE","syscall":"listen","address":"0.0.0.0","port":4567},"stack":"Error: listen EADDRINUSE: address already in use 0.0.0.0:4567\n    at Server.setupListenHandle [as _listen2] (net.js:1313:16)\n    at listenInCluster (net.js:1361:12)\n    at doListen (net.js:1500:7)\n    at processTicksAndRejections (internal/process/task_queues.js:85:21)","exception":true,"date":"Mon May 25 2020 09:02:29 GMT+0000 (Coordinated Universal Time)","process":{"pid":154,"uid":0,"gid":0,"cwd":"/nodebb","execPath":"/usr/local/bin/node","version":"v12.16.3","argv":["/usr/local/bin/node","/nodebb/app.js"],"memoryUsage":{"rss":137650176,"heapTotal":109584384,"heapUsed":80475200,"external":1559251}},"os":{"loadavg":[3.6689453125,2.95263671875,2.63623046875],"uptime":13644475},"trace":[{"column":16,"file":"net.js","function":"Server.setupListenHandle [as _listen2]","line":1313,"method":"setupListenHandle [as _listen2]","native":false},{"column":12,"file":"net.js","function":"listenInCluster","line":1361,"method":null,"native":false},{"column":7,"file":"net.js","function":"doListen","line":1500,"method":null,"native":false},{"column":21,"file":"internal/process/task_queues.js","function":"processTicksAndRejections","line":85,"method":null,"native":false}]}
    2020-05-25T09:02:29.733Z [4567/154] - error: listen EADDRINUSE: address already in use 0.0.0.0:4567 {"code":"EADDRINUSE","errno":"EADDRINUSE","syscall":"listen","address":"0.0.0.0","port":4567}
    2020-05-25T09:02:29.733Z [4567/154] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
    2020-05-25T09:02:29.735Z [4567/154] - error: Error [ERR_SERVER_NOT_RUNNING]: Server is not running.
        at Server.close (net.js:1604:12)
        at Object.onceWrapper (events.js:416:28)
        at Server.emit (events.js:322:22)
        at emitCloseNT (net.js:1657:8)
        at processTicksAndRejections (internal/process/task_queues.js:83:21)
        at runNextTicks (internal/process/task_queues.js:66:3)
        at processImmediate (internal/timers.js:429:9)
    [cluster] Child Process (154) has exited (code: 1, signal: null)
    [cluster] Spinning up another process...
    

    The config file generated after the web installer is:

    {
        "url": "http://sub.domain.tld",
        "secret": "2fe83efb-3317-4e9e-98c4-b590353711df",
        "database": "redis",
        "port": 4567,
        "redis": {
            "host": "nodebb-redis",
            "port": "6379",
            "password": "",
            "database": "0"
        }
    }
    

    If I try to stop:

    # node ./nodebb stop
    NodeBB is already stopped.
    

    If I search for running processes:

    b# ps -aux
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root         1  0.0  0.0   4268   616 pts/0    Ss   09:06   0:00 /bin/sh -c node ./nodebb build ;  node ./nodebb start ; bash
    root        91  0.0  0.0  18172  2076 pts/1    Ss+  09:06   0:00 bash
    root        99  0.0  0.0 606504 25060 ?        Ssl  09:08   0:00 node loader.js
    root       117  0.6  0.2 967676 97928 ?        Sl   09:08   0:04 /usr/local/bin/node /nodebb/app.js
    root       183  0.0  0.0  18176  2092 pts/0    S    09:08   0:00 bash
    root       258  0.0  0.0  36624  1524 pts/0    R+   09:19   0:00 ps -aux
    

    It seems that nodebb is already running, but why?


  • Global Moderator

    The web installer automatically starts NodeBB when it finishes.



  • @PitaJ I know that, but this is not the error I am facing.
    Actually, I opened a parallel GitHub issue (for my first message) and they find out the root cause.

    My configuration file is not correct, the "session_store" should be an object like "redis" and not a simple string.



  • Problem solved, for the record I have added all file on my GitHub: https://github.com/LM1LC3N7/Dockerfiles/blob/master/nodebb/README.md



Suggested Topics

| |