NodeBB not working with Phusion Passenger?

Created on 18 Mar 2017  Â·  30Comments  Â·  Source: NodeBB/NodeBB

When I run NodeBB without passanger using reserved port everything is OK. There is problem when Passenger is involved.

My configuration:

Passenger v5.0.30
Node.js v4.7.2
OS: FreeBSD 10.3-STABLE

nodeBB version:
git clone -b v1.x.x https://github.com/NodeBB/NodeBB.git
Configured using ./nodebb Set up for use of MongoDB.

Problem:
After I try to load page I get error page from Passanger and nodeBB is not loading

In errorlog

17/3 15:34:42 [92102] - �[32minfo�[39m: NodeBB v1.4.5 Copyright (C) 2013-2017 NodeBB Inc.
17/3 15:34:42 [92102] - �[32minfo�[39m: This program comes with ABSOLUTELY NO WARRANTY.
17/3 15:34:42 [92102] - �[32minfo�[39m: This is free software, and you are welcome to redistribute it under certain conditions.
17/3 15:34:42 [92102] - �[32minfo�[39m:
17/3 15:34:42 [92102] - �[32minfo�[39m: Time: Fri Mar 17 2017 15:34:42 GMT+0100 (CET)
17/3 15:34:42 [92102] - �[32minfo�[39m: Initializing NodeBB v1.4.5
Error: Cannot find module './node_modules/mongodb/package.json'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at module.checkCompatibility (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/database/mongo.js:171:31)
at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:760:23
at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:166:37
at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:718:13
at async.forEachOf.async.eachOf (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:233:13)
at _parallel (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:717:9)
at Object.async.parallel (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:731:9)

After I edit:
/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/database/mongo.js
kine number: 171
Substitution of:
var mongoPkg = require.main.require('./node_modules/mongodb/package.json');
to:
var mongoPkg = require.main.require('/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/mongodb/package.json');
Page is loading but does not have full functionality (e.g. I can't post to the forum).

Now inside log file:

App 9980 stdout:
App 9980 stdout: 17/3 15:42:41 [9980] - info: NodeBB v1.4.5 Copyright (C) 2013-2017 NodeBB Inc.
App 9980 stdout: 17/3 15:42:41 [9980] - info: This program comes with ABSOLUTELY NO WARRANTY.
App 9980 stdout: 17/3 15:42:41 [9980] - info: This is free software, and you are welcome to redistribute it under certain conditions.
App 9980 stdout: 17/3 15:42:41 [9980] - info:
App 9980 stdout: 17/3 15:42:41 [9980] - info: Time: Fri Mar 17 2017 15:42:41 GMT+0100 (CET)
App 9980 stdout: 17/3 15:42:41 [9980] - info: Initializing NodeBB v1.4.5
App 9980 stdout: 17/3 15:42:43 [9980] - info: [socket.io] Restricting access to origin: http://nodebb.somesite.net:*
App 9980 stdout: 17/3 15:42:43 [9980] - warn: [plugins] Unable to parse library for: nodebb-plugin-composer-default
App 9980 stdout: 17/3 15:42:43 [9980] - warn: [plugins] Unable to parse library for: nodebb-theme-persona
App 9980 stderr: 17/3 15:42:43 [9980] - error: Error: Cannot find module './src/socket.io/plugins'
App 9980 stderr: at Function.Module._resolveFilename (module.js:325:15)
App 9980 stderr: at Function.Module._load (module.js:276:25)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-plugin-composer-default/library.js:10:31)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.Plugins.requireLibrary (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins.js:40:33)
App 9980 stderr: at registerHooks (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:138:13)
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:81:6
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:718:13
App 9980 stderr: at async.forEachOf.async.eachOf (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:233:13)
App 9980 stderr: at _parallel (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:717:9)
App 9980 stderr: at Object.async.parallel (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:731:9)
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:79:10
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:346:4
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:726:13
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:52:16
App 9980 stderr: at done (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:246:17)
App 9980 stderr: 17/3 15:42:43 [9980] - error: Error: Cannot find module 'string'
App 9980 stderr: at Function.Module._resolveFilename (module.js:325:15)
App 9980 stderr: at Function.Module._load (module.js:276:25)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-theme-persona/library.js:3:22)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.Plugins.requireLibrary (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins.js:40:33)
App 9980 stderr: at registerHooks (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:138:13)
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:81:6
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:718:13
App 9980 stderr: at async.forEachOf.async.eachOf (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:233:13)
App 9980 stderr: at _parallel (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:717:9)
App 9980 stderr: at Object.async.parallel (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:731:9)
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:79:10
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:346:4
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:726:13
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:52:16
App 9980 stderr: at done (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:246:17)
App 9980 stderr: 17/3 15:42:43 [9980] - error: Error: Cannot find module './src/groups'
App 9980 stderr: at Function.Module._resolveFilename (module.js:325:15)
App 9980 stderr: at Function.Module._load (module.js:276:25)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-rewards-essentials/lib/rewards.js:4:27)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stdout: 17/3 15:42:43 [9980] - warn: [plugins] Unable to parse library for: nodebb-rewards-essentials
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-rewards-essentials/library.js:10:18)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.Plugins.requireLibrary (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins.js:40:33)
App 9980 stderr: at registerHooks (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:138:13)
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:81:6
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:718:13
App 9980 stderr: at async.forEachOf.async.eachOf (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:233:13)
App 9980 stderr: 17/3 15:42:43 [9980] - error: Error: Cannot find module './src/settings'
App 9980 stderr: at Function.Module._resolveFilename (module.js:325:15)
App 9980 stderr: at Function.Module._load (module.js:276:25)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-plugin-emoji-extended/lib/settings.js:7:29)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-plugin-emoji-extended/lib/sets/active.js:6:16)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stdout: 17/3 15:42:43 [9980] - warn: [plugins] Unable to parse library for: nodebb-plugin-emoji-extended
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-plugin-emoji-extended/lib/sets/controller.js:3:14)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: 17/3 15:42:43 [9980] - error: Error: Cannot find module './src/meta'
App 9980 stderr: at Function.Module._resolveFilename (module.js:325:15)
App 9980 stderr: at Function.Module._load (module.js:276:25)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-plugin-emoji-one/lib/settings.js:6:25)
App 9980 stdout: 17/3 15:42:43 [9980] - warn: [plugins] Unable to parse library for: nodebb-plugin-emoji-one
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.<anonymous> (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/nodebb-plugin-emoji-one/lib/controller.js:6:16)
App 9980 stderr: at Module._compile (module.js:409:26)
App 9980 stderr: at Object.Module._extensions..js (module.js:416:10)
App 9980 stderr: at Module.load (module.js:343:32)
App 9980 stderr: at Function.Module._load (module.js:300:12)
App 9980 stderr: at Module.require (module.js:353:17)
App 9980 stderr: at require (internal/module.js:12:17)
App 9980 stderr: at Object.Plugins.requireLibrary (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins.js:40:33)
App 9980 stderr: at registerHooks (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:138:13)
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/src/plugins/load.js:81:6
App 9980 stderr: at /usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:718:13
App 9980 stderr: at async.forEachOf.async.eachOf (/usr/home/someuser/domains/nodebb.somesite.net/public_nodejs/node_modules/async/lib/async.js:233:13)
App 9980 stdout: 17/3 15:42:43 [9980] - info: Routes added
App 9980 stdout: 17/3 15:42:43 [9980] - info: NodeBB Ready
App 9980 stdout: 17/3 15:42:43 [9980] - info: Enabling 'trust proxy'
App 9980 stdout: 17/3 15:42:43 [9980] - info: NodeBB is now listening on: 0.0.0.0:4567

I do not have any problems with running other Node.js apps with use of Passenger. It seems like Node.js modules have some problems with loading full path.

All 30 comments

Phusion Passenger is handling the running of NodeBB itself, I'm assuming? Looks like you need to change the working directory to the path where NodeBB is installed. It's likely running from... somewhere else.

As this is a config issue, I'm closing, but feel free to continue discussion at our community forum 😄

Most shared hostings using Phusion Passenger won't set the CWD to sites directory, because it's never recommender anywhere and it's the default passenger config.

However, most software deals with it - namely every Django-based app - because it builds the absolute paths on the fly.

In node this can be achieved by building relative paths as absolute, but relative to __dirname - it would probably be an appreciated improvement ;)

What makes you think that is a configuration issue? I remember there was no issues with running version 0.9.X with Passenger.

This isn't an issue with CWD per say. It's actually due to require.main not referencing app.js, but instead referencing whatever module it is that Passenger uses to execute app.js. It may be possible to add a workaround to app.js where, if require.main !== module, app.js forks itself.

That would force require.main to be a reference to app.js instead. We are also discussing providing a more defined API for plugins which might avoid the require.main.require or module.parent.require usage entirely.

In node this can be achieved by building relative paths as absolute, but relative to __dirname - it would probably be an appreciated improvement ;)

This is already done everywhere I can think of. Especially since require automatically does it. If you can find places where we do use the paths directly, please open an issue and we'll fix it, as that is a bug.

I'm not very familiar with node, but looking at the first workaround OP tried that made NodeBB work, it looks like referencing each imported module by a full, absolute path would solve the issue (especially that the next error he faced looks very similar).

While I can understand that your software relies on being in a particular directory, it may actually benefit from ditching that dependency - either by building absolute paths or by changing the working directory upon app initialization. This will not only make passenger-based environments to work, but also make cron-based autostart more readable (as a crone rule won't have to cd by itself).

What I'm saying is that it's not the path, or the working directory, that's the issue.

The issue is that Passenger is running app.js as a submodule, which messes up how require.main.require works. I've just removed the specific usage of require.main.require in the NodeBB database module. That should allow NodeBB to work fine when launched as a submodule, but many plugins, which do use require.main.require, will still be broken for now. This fix should be in the master branch soon.

It you want this fix now, you can run git fetch && git checkout patch-5538. It resolves the error

Error: Cannot find module './node_modules/mongodb/package.json'

It you want this fix now, you can run git fetch && git checkout patch-5538. It resolves the error

@pitaj it fixed mongodb issues but not problems with other modules

By other modules, do you mean plugins?

@pitaj

Well this is what I get when I try to load page after webinstaller "finished". Error page:

Web application could not be started
An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger. Please read this article for more information about this problem.
Raw process output:

(node:35443) DeprecationWarning: 'GLOBAL' is deprecated, use 'global'
10/4 08:14:49 [35443] - verbose: * using configuration stored in: /usr/home/webuser/services/nodebb/public_nodejs/config.json
10/4 08:14:49 [35443] - info: NodeBB v1.4.5 Copyright (C) 2013-2017 NodeBB Inc.
10/4 08:14:49 [35443] - info: This program comes with ABSOLUTELY NO WARRANTY.
10/4 08:14:49 [35443] - info: This is free software, and you are welcome to redistribute it under certain conditions.
10/4 08:14:49 [35443] - info:  
10/4 08:14:49 [35443] - info: Initializing NodeBB v1.4.5
10/4 08:14:49 [35443] - verbose: * using mongo store at mongo.mydomain.net:27017
10/4 08:14:49 [35443] - verbose: * using themes stored in: /usr/home/webuser/services/nodebb/public_nodejs/node_modules

Error ID
    707febdb
Application root
    /usr/home/webuser/services/nodebb/public_nodejs
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV, NODE_ENV and PASSENGER_APP_ENV)
    development
User and groups

    uid=1745(webuser) gid=1000 groups=1000,666

Environment variables

    PASSENGER_APP_ENV=development
    NODE_ENV=development
    WSGI_ENV=development
    RACK_ENV=development
    RAILS_ENV=development
    NODE_PATH=/usr/local/lib/ruby/gems/2.3/gems/passenger-5.0.30/src/nodejs_supportlib
    PYTHONUNBUFFERED=1
    IN_PASSENGER=1
    _system_type=BSD
    LC_MONETARY=pl_PL.ISO8859-2
    rvm_bin_path=/home/webuser/.rvm/bin
    RC_PID=42184
    PASSENGER_USE_FEEDBACK_FD=true
    EDITOR=/usr/local/bin/nano
    MACHINE=amd64
    rvm_version=1.29.1 (latest)
    RUBY_VERSION=ruby-2.2.6
    GEM_HOME=/home/webuser/.rvm/gems/ruby-2.2.6
    USER=webuser
    LC_COLLATE=pl_PL.ISO8859-2
    PWD=/usr/home/webuser/services/nodebb/public_nodejs
    _system_version=10.3
    HOME=/home/webuser
    LC_CTYPE=pl_PL.ISO8859-2
    _system_name=FreeBSD
    CLICOLOR=YES
    _system_arch=x86_64
    GEM_PATH=/home/webuser/.rvm/gems/ruby-2.2.6:/home/webuser/.rvm/gems/ruby-2.2.6@global
    LC_NUMERIC=pl_PL.ISO8859-2
    MACHINE_ARCH=amd64
    PASSENGER_DEBUG_DIR=/tmp/passenger.spawn-debug.3DhpaqdGKd
    md_enc=ISO8859-2
    rvm_path=/home/webuser/.rvm
    SHELL=/usr/local/bin/bash
    LC_MESSAGES=pl_PL.ISO8859-2
    rvm_prefix=/home/webuser
    SHLVL=0
    LOGNAME=webuser
    MY_RUBY_HOME=/home/webuser/.rvm/rubies/ruby-2.2.6
    PATH=/home/webuser/.rvm/gems/ruby-2.2.6/bin:/home/webuser/.rvm/gems/ruby-2.2.6@global/bin:/home/webuser/.rvm/rubies/ruby-2.2.6/bin:/home/webuser/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/webuser/composer:/home/webuser/.rvm/bin
    PS1=[\u\[\033[1;31m\]@\[\033[0m\]\h]\[\033[1;31m\]:\[\033[0m\]<\w>\[\033[1;31m\]\$ \[\033[0m\]
    HISTSIZE=100000000
    IRBRC=/home/webuser/.rvm/rubies/ruby-2.2.6/.irbrc
    SERVER_SOFTWARE=nginx/1.10.2 Phusion_Passenger/5.0.30
    LC_TIME=pl_PL.ISO8859-2

Ulimits

    cpu time               (seconds, -t)  unlimited
    file size           (512-blocks, -f)  unlimited
    data seg size           (kbytes, -d)  33554432
    stack size              (kbytes, -s)  524288
    core file size      (512-blocks, -c)  unlimited
    max memory size         (kbytes, -m)  unlimited
    locked memory           (kbytes, -l)  unlimited
    max user processes              (-u)  89999
    open files                      (-n)  7545987
    virtual mem size        (kbytes, -v)  unlimited
    swap limit              (kbytes, -w)  unlimited
    sbsize                   (bytes, -b)  unlimited
    pseudo-terminals                (-p)  unlimited

System metrics

    ------------- General -------------
    Kernel version    : 10.3-STABLE
    Uptime            : 60d 2h 11m 36s
    Load averages     : 8.73%, 8.94%, 9.07%

    ------------- CPU -------------
    Number of CPUs    :   32
    Average CPU usage :  39%  --  21% user,   0% nice,  18% system,  61% idle
      CPU 1           :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 2           :  50%  --  33% user,   0% nice,  17% system,  50% idle
      CPU 3           :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 4           :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 5           :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 6           : 100%  --  83% user,   0% nice,  17% system,   0% idle
      CPU 7           :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 8           :  67%  --  67% user,   0% nice,   0% system,  33% idle
      CPU 9           :  17%  --  17% user,   0% nice,   0% system,  83% idle
      CPU 10          :  67%  --  67% user,   0% nice,   0% system,  33% idle
      CPU 11          :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 12          :  33%  --   0% user,   0% nice,  33% system,  67% idle
      CPU 13          :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 14          : 100%  --  17% user,   0% nice,  83% system,   0% idle
      CPU 15          :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 16          : 100%  -- 100% user,   0% nice,   0% system,   0% idle
      CPU 17          :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 18          :  17%  --  17% user,   0% nice,   0% system,  83% idle
      CPU 19          :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 20          : 100%  --   0% user,   0% nice, 100% system,   0% idle
      CPU 21          :  33%  --  17% user,   0% nice,  17% system,  67% idle
      CPU 22          :  17%  --  17% user,   0% nice,   0% system,  83% idle
      CPU 23          :  83%  --  67% user,   0% nice,  17% system,  17% idle
      CPU 24          :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 25          :  67%  --  50% user,   0% nice,  17% system,  33% idle
      CPU 26          :  33%  --  17% user,   0% nice,  17% system,  67% idle
      CPU 27          :  33%  --  17% user,   0% nice,  17% system,  67% idle
      CPU 28          :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 29          : 100%  --  33% user,   0% nice,  67% system,   0% idle
      CPU 30          :  17%  --   0% user,   0% nice,  17% system,  83% idle
      CPU 31          :   0%  --   0% user,   0% nice,   0% system, 100% idle
      CPU 32          : 100%  --  50% user,   0% nice,  50% system,   0% idle

    ------------- Memory -------------
    RAM total         : 262013 MB
    RAM used          : 115394 MB (44%)
    RAM free          : 146618 MB
    Swap total        :   5120 MB
    Swap used         :   1076 MB (21%)
    Swap free         :   4043 MB


error.log contains:

Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3

public_nodejs/config.json

{
    "url": "http://localhost:4567",
    "secret": **ERASED**,
    "database": "mongo",
    "port": 4567,
    "mongo": {
        "host": "mongo.mydomain.net",
        "port": "27017",
        "username": "nodebb",
        "password": **ERASED**,
        "database": "nodebb"
    }
}

Try running npm install and ./nodebb upgrade. That should resolve that error.

@pitaj

$ npm install
$ ./nodebb upgrade
1. Bringing base dependencies up to date... OK
2. Checking installed plugins for updates... OK
3. Updating NodeBB data store schema...
module.js:327
    throw err;
    ^

Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

Error: undefined

When you run NodeBB normally, you must be getting that error, then. Were there any errors when running npm install?

Can you try running npm ls nodemailer-smtp-transport? It should output something like this:

+-- [email protected]
| `-- [email protected]
`-- [email protected]

@pitaj

>$ npm ls nodemailer-smtp-transport
[email protected] /usr/home/webuser/services/nodebb/public_nodejs
├─┬ [email protected]
│ └── [email protected] 
└── [email protected] 

Were there any errors when running npm install?

No, there were not.

Does running NodeBB without going through Phusion work? Try running with ./nodebb dev

Well It did work w/o Passenger ( as I stated in initial message here ) like a month before this issue report. But I need it to work with Passenger.

And about your method of runing

$ ./nodebb dev

NodeBB v1.4.5 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).

11/4 11:19:37 [3158] - verbose: * using configuration stored in: /usr/home/webuser/services/nodebb/public_nodejs/config.json
11/4 11:19:38 [3158] - info: Initializing NodeBB v1.4.5
11/4 11:19:38 [3158] - verbose: * using mongo store at mongo.mydomain.net:27017
11/4 11:19:38 [3158] - verbose: * using themes stored in: /usr/home/webuser/services/nodebb/public_nodejs/node_modules
11/4 11:19:39 [3158] - error:  Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
module.js:327
    throw err;
    ^

Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
[cluster] Child Process (3158) has exited (code: 7, signal: null)
[cluster] Spinning up another process...
11/4 11:19:40 [3501] - verbose: * using configuration stored in: /usr/home/webuser/services/nodebb/public_nodejs/config.json
11/4 11:19:40 [3501] - info: Initializing NodeBB v1.4.5
11/4 11:19:40 [3501] - verbose: * using mongo store at mongo.mydomain.net:27017
11/4 11:19:40 [3501] - verbose: * using themes stored in: /usr/home/webuser/services/nodebb/public_nodejs/node_modules
11/4 11:19:42 [3501] - error:  Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
module.js:327
    throw err;
    ^

Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
[cluster] Child Process (3501) has exited (code: 7, signal: null)
[cluster] Spinning up another process...
11/4 11:19:43 [3557] - verbose: * using configuration stored in: /usr/home/webuser/services/nodebb/public_nodejs/config.json
11/4 11:19:43 [3557] - info: Initializing NodeBB v1.4.5
11/4 11:19:43 [3557] - verbose: * using mongo store at mongo.mydomain.net:27017
11/4 11:19:43 [3557] - verbose: * using themes stored in: /usr/home/webuser/services/nodebb/public_nodejs/node_modules
11/4 11:19:44 [3557] - error:  Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
module.js:327
    throw err;
    ^

Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
[cluster] Child Process (3557) has exited (code: 7, signal: null)
[cluster] Spinning up another process...
11/4 11:19:45 [3609] - verbose: * using configuration stored in: /usr/home/webuser/services/nodebb/public_nodejs/config.json
11/4 11:19:45 [3609] - info: Initializing NodeBB v1.4.5
11/4 11:19:45 [3609] - verbose: * using mongo store at mongo.mydomain.net:27017
11/4 11:19:45 [3609] - verbose: * using themes stored in: /usr/home/webuser/services/nodebb/public_nodejs/node_modules
11/4 11:19:46 [3609] - error:  Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
module.js:327
    throw err;
    ^

Error: Cannot find module 'nodemailer-smtp-transport'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/home/webuser/services/nodebb/public_nodejs/src/emailer.js:9:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
3 restarts in 10 seconds, most likely an error on startup. Halting.

Ok so it obviously isn't working without passenger now. Can you try running these commands

git reset --hard origin/master
./nodebb upgrade
./nodebb dev

And see if that fixes your problem? Thanks

@pitaj it did not. But new installation did solve problem.
But on the other hand it brings other problems.

First of all nodebb works fine without Passenger, but when run with Passenger there is limited functionality working - I can't reply to posts etc. More details soon, as I'm collecting data ( logs, etc ).

When trying to "Reply->Reply as topic" firefox web console output:

TypeError: config['composer-default'] is undefined
Stack trace:
@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:11:1
v.event.dispatch@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:2:12490
v.event.add/g.handle@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:2:10446
.trigger@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:3:9373
.trigger/<@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:3:9909
.each@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:1:2888
v.prototype.each@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:1:1077
.trigger@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:3:9888
l/</<@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:14:3628
e/<@http://nodebb2.mydomain.net/assets/nodebb.min.js?v=5ql7q9de2hd:14:31591

When trying to click "New topic" button

TypeError: config['composer-default'] is undefined  [Learn More]

No trace of errors in nodebb log files or system log files so far. Only javascript ( I guess ) related things so far.

After lading /admin page

TypeError: r.getContext is not a function
[Learn More]dashboard.js:1:3059

Yes, as I mentioned, the fixes I made will not enable plugins to work. I'll see if I can fix that.

git pull

checked out of curiosity what happens, and I could not log in because after clicking "Login" button of login form it becomes inactive.

npm install

still same effect

./nodebb restart

Same symphtoms. Here I noticed that after f5 i get message "Login Unsuccessful" ( both with correct and incorrect password ).

Web console after mentioned f5

TypeError: $(...).size is not a function
[Learn More]login.js:1:811
nodebb-plugin-emoji-extended ERROR - Object { message: "[[error:invalid-event]]" }nodebb.min.js:12:20514

nodebb-plugin-emoji-extended ERROR - Object { message: "[[error:invalid-event]]" }nodebb.min.js:12:20514

nodebb-plugin-emoji-extended ERROR - Object { message: "[[error:invalid-event]]" }nodebb.min.js:12:20514

nodebb-plugin-emoji-extended ERROR - Object { message: "[[error:invalid-event]]" }nodebb.min.js:12:20514

Today I did git pull, upgraded nodeBB, did npm install and restarted it and it seems to work OK. Seems like problem solved so far.

@pitaj

After fresh installation it started to display messages like this when I load nodebb start page and after I log in when i try to write a post and it fails. Same message and behavior appears on all servers I have access to. Every server has exactly the same configuration.

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.

config.json is same as mentioned in earlier post in this thread.
May this be related to this issue.

I have no idea why it works on old installation I updated the way mentioned in last post. Upgrading new fresh installations of nodebb does not solve database connection problems.

@pitaj

Should I add new issue? Problem is already described here in case you or someone else got any ideas what may cause this errors.

@alienfromouterspace the url field in config.json must match the URL at which users access your site. For instance, if your forum is at https://forum.example.com then your url field should be set to exactly that. You can set the port separately with a port field in config.json:

"url": "https://forum.example.com",
"port": "4567",

If that doesn't fix your issue then please make a post on our forums at https://community.nodebb.org or open a new issue.

Was this page helpful?
0 / 5 - 0 ratings