Minifer.js not found; nodebb.min.js not created
-
I'm seeing the following error when starting NodeBB on my production server:
module.js:340 throw err; ^ Error: Cannot find module '/minifier.js' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:935:3
The same code runs correctly on dev and our staging server (Heroku). We are running on Ubuntu and NodeBB is being started by Upstart. As far as I can tell the minifer code is in place - this is the file on the prod server:
1623 Mar 21 12:39 minifier.js
I've run npm install in the nodebb folder and everything is up to date. Here is the verbose log from NodeBB:
21/3 13:12 [24179] - info: NodeBB v0.9.2 Copyright (C) 2013-2014 NodeBB Inc. 21/3 13:12 [24179] - info: This program comes with ABSOLUTELY NO WARRANTY. 21/3 13:12 [24179] - info: This is free software, and you are welcome to redistribute it under certain conditions. 21/3 13:12 [24179] - info: 21/3 13:12 [24179] - info: Time: Mon Mar 21 2016 13:12:54 GMT-0500 (PET) 21/3 13:12 [24179] - info: Initializing NodeBB v0.9.2 21/3 13:12 [24179] - info: Environment: production 21/3 13:12 [24179] - verbose: * using mongo store at xxx.xxx.xxx.xxx:xxxx 21/3 13:12 [24179] - verbose: * using themes stored in: /var/www/blahblahblah/node_modules 21/3 13:12 [24179] - info: [database] Checking database indices. 21/3 13:13 [24179] - verbose: Checking dependencies for outdated modules 21/3 13:13 [24179] - verbose: [notifications.init] Registering jobs. 21/3 13:13 [24179] - verbose: [meta/css] Minifying LESS/CSS 21/3 13:13 [24179] - verbose: [sounds] Sounds OK 21/3 13:13 [24179] - verbose: [meta/templates] Compiling templates 21/3 13:13 [24179] - verbose: [meta/templates] Successfully compiled templates. 21/3 13:13 [24179] - verbose: [meta/css] admin.css committed to disk. 21/3 13:13 [24179] - verbose: [meta/css] stylesheet.css committed to disk.
The log always stops at this point. It seems to be the case that the following line in webserver.js fails:
async.apply(!skipJS ? meta.js.minify : meta.js.getFromFile, app.enabled('minification')),
The user running nodeBB has write permission to the /public folder where the nodebb.min.js will be created.
Interestingly, if I manually add the nodebb.min.js to the /public folder, hack that line to force meta.js.getFromFIle, NodeBB starts but the login page is blank apart from the header and there are no JS script errors.
-
It's failing on this line in /src/meta/js.js:
var minifier = Meta.js.minifierProc = fork('minifier.js', [], forkProcessParams),
Are there some special permissions or configuration I need to setup to allow a process to be forked?
I've tried running node with each of the following command lines, both giving similar results:
exec node $LIVE_DIR/loader.js --no-silent --no-daemon >> /var/log/blahblahblah/nodebb.log exec node $LIVE_DIR/app.js >> /var/log/blahblahblah/nodebb.log
-
Found the answer - The script starting NodeBB must be in the nodebb directory otherwise the minifier will fail as above. Changed my Upstart script as follows:
cd $LIVE_DIR exec node app.js >> /var/log/blahblahblah/nodebb.log