@wktang It's a good question, I had the same problem trying to post a tutorial the other week. I solved it by editing in each piece bit by bit. Dirty work-around, but hey, what can you do when it doesn't give you clear outlines.
Posts made by meshmellow
RE: Editing post flagged as spam by Akismet
Getting NodeBB and plugins setup with Heroku (and MongoDB)
Trying to setup NodeBB with Heroku
Originally I had a lot of problems trying to get NodeBB as a Heroku app running, so I thought I would make a guide on how I did it in case anyone else runs into the same issues I faced.
Full disclosure: Running Windows 8.1 Pro and I am inexperienced with Heroku, NodeJS, git and all this. But this is what I had to do to get my setup working, I hope it can help someone.
I started out by following this step by step, but I ran into some problems
Here's what I did differently to get my NodeBB working
I am assuming you already have a Heroku account setup in this tutorial.
Step 1) Open up command prompt and navigate to the root folder
Step 2) Clone the NodeBB repository to the path where you want your NodeBB
git clone -b v1.x.x https://github.com/NodeBB/NodeBB.git /path/to/where/you/want/nodeBB/
For example - git clone -b v1.x.x https://github.com/NodeBB/NodeBB.git /nodeBB-local/
Step 3) Go to the folder where you put NodeBB
For example - cd /nodeBB-local/
Step 4) Install dependencies locally
npm install --production
Step 5) Create your Heroku App
Remember the URL for your App (ie.
Step 6) If you have a mongoDB already you can use that information instead
But if you don't have one and still want to try out NodeBB with Heroku (and if you MUST use Heroku with MongoDB, I'd say it seems there are easier alternatives) you can setup a Sandbox MongoLab DB for now:
Step 6.a) In command prompt while logged into Heroku with the right app
heroku addons:create mongolab
Step 6.b) After it has been created, check your config variables:
If your MongoLab addon got added correctly it will show you your MongoDB information
MONGODB_URI => mongodb://mongoDB_username:mongoDB_password@mongoDB_host:mongoDB_port/mongoDB_db
Since this is pulled from your Heroku config variables there might be an easier way of getting your DB information from there into NodeBB, and it would make it a lot easier if your mongoDB host or information changes for whatever reason.
Step 7) If everything has gone through without error, it's time to setup nodeBB
node app --setup
This is where you will tell NodeBB what Heroku App URL and database to use
HOST IP / Address: mongoDB_host
MongoDB Username: mongoDB_username
Database to use: mongoDB_db
Step 8.) Create the Procfile for Heroku
echo web: node app.js > Procfile
The documentation tells you to type
echo "web: node loader.js --no daemon", but this didn't work for me.
Repeatedly crashed on trying to start up, and so this workaround allowed me to start it and run it fine.
However, it prevents the use of the Restart app functionality in the Admin API! (Reload still seems to work))
Having to restart the Heroku app manually every time you want to install a plugin will also cause some issues as covered under the Plugins section.
Step 9) Commit the Procfile, config.json and package.json
git add -f Procfile config.json package.json && git commit -am "adding Procfile and configs for Heroku"
Step 10) Push the v1.x.x branch to heroku as master
git push -u heroku v1.x.x:master
Step 11) Scale the web dyno up
heroku ps:scale web=1
Step 12 a.) Check to see if the app is running!
Step 12 b.) Check your logs if not
Now to install plugins on a NodeBB running on Heroku seems to be a bit different since you can't do it through their Admin API.
Your plugin will gone on restart because Heroku doesn't save your generated files permanently!
So instead you will have to install a plugin as a dependency so it gets included with the build, for this example I will use the Gravatar plugin, because as you might have guessed, Heroku wont save your avatars that are uploaded either. (NodeBB will save the URL reference to database, resulting in broken images)
Step 1) Install the nodebb-plugin-gravatar as a dependency and save it to the package.json
npm install nodebb-plugin-gravatar --save
Step 2) Commit the package.json to the next push
git add -f package.json && git commit -am "updating package.json"
Step 3) If you've installed all your desired plugins then you can push it to Heroku again and then activate your plugins through the NodeBB Admin API
git push heroku v1.x.x:master
You will have to locally add the images to the appropriate folders such as the site logo for example (upload/system/site-logo.png) because if you upload them through the Admin API they will also disappear due to how Heroku stores files
Image Hosting APIs alternatives might be worth looking into
RE: (SOLVED) Pushing to Heroku
I think I got it pushed to the Heroku app because it did the building process it does with my own app, and I can see nodeBB in the Heroku logs starting up, but it crashes right away now. I am thinking it might have something to do with the MongoDB connection? (It's a Sandbox MongoLabs connection, but it works for my other app and when I run NodeBB locally it makes changes to to the online MongoLab DB as confirmed through their administrative tools)
These are my Heroku logs:
2016-06-15T02:54:01.203018+00:00 app[web.1]: > firstname.lastname@example.org start /app
2016-06-15T02:54:01.203024+00:00 app[web.1]: > node loader.js
2016-06-15T02:54:03.280111+00:00 heroku[web.1]: Process exited with status 0
I might have done something horribly wrong when building but I am at a loss for what it could be. After cloning the NodeBB from your git, and then trying to push it to my app with a fresh repo clone, it tells me what the srcref for master isn't there when I try "git push heroku master", however if I try what the tutorial says "git push -u heroku v1.x.x:master" it says that it's up to date instead and nothing gets pushed. This is when I tried setting my git heroku branch to master and pushing anyway (it uploaded and the app crash)
EDIT: I am going to try and do a fresh clone later when I get back from work and create a new Heroku app to attempt this from Step 1, and I will detail my process for you guys so that you have a better understanding of what I might be doing wrong.
(SOLVED) Pushing to Heroku
After setting the heroku remote to the master manually, I managed to push it to Heroku. The app kept crashing when trying to run loader.js, so O set the procfile to instead run app.js directly, and now it boots up. I realize I lose the functionality of restarting through the admin api but it's a trade-off I'm willing to make unless someone has any better ideas. I just wanna use nodeBB for my online game, it just flows and feels nice to use. Thanks!
I will return to update this if any other complications arise.
I cannot for the life of me manage to push NodeBB to Heroku...
I have followed ( https://nodebb.readthedocs.io/en/latest/installing/cloud/heroku.html ) up to step 10 where our setups deviate, where I am using MongoDB instead (I got it set up and working, it connects to the MongoDB database after running the --setup command on NodeBB), NodeBB also manages to run locally.
However, once I get to committing the Procfile (It's been created and it's in the folder),
This command: "git rm npm-shrinkwrap.json && git add -f Procfile config.json package.json && git commit -am "adding Procfile and configs for Heroku" " does not work because it tells me npm-shrinkwrapjson doesn't exist, which is fine I guess because it's only trying to remove it? Either way, I try and commit both the Procfile and the package.json but nothing happens, it simply says that everything is up to date (after git push -u heroku v1.0.0:master).
But looking at my Heroku app, it looks totally blank, nothing has been pushed. Attempting to scale the web dynos with "heroku ps:scale web=1" simply gives me an error saying that the formation couldn't be found which implies the Procfile isn't getting the web loader.js running, so I don't know where it's all going wrong, to be honest.