How to set up a NodeBB dev environment
-
I've seen a few people around here have been submitting PRs for NodeBB, and I'm quite interested in getting familiarised with the project and possibly contributing.
How did you guys go about setting up a dev environment for it? Did anybody find any decent information online? I'd appreciate any information that could help me.
I never bothered with Discourse, because the consensus seemed to be that it was a nightmare to set up (and also, fuck Jeff). Fingers crossed that NodeBB is much simpler!
-
The instructions here focus on Cloud9, but you should be able to follow along in whatever environment you have ;)
-
I think you can even host it for free on openshift
-
My intention is to get a Windows dev environment set up. I'll document the setup if it's not straightforward.
-
Feature request: A plugin that forces any list to count from "1" despite whatever the user input was. And any line starting with a number followed by a dot should be interpreted as a numbered list item.
-
I created a VM and followed this:
http://nodebb-francais.readthedocs.org/projects/nodebb/en/latest/installing/os/ubuntu.html
It's pretty easy to follow and get set up and running.
Also, I learned that when starting up NodeBB, you get actual debugging logging info in the console when you do:$ ./nodebb dev
...instead of:
$ ./nodebb start
I've heard people talk about setting up node debugging with IntelliJ. I haven't gotten to the point of setting up an actual debugging environment.
-
I've heard people talk about setting up node debugging with IntelliJ. I haven't gotten to the point of setting up an actual debugging environment.
I've got node debugging working with webstorm. I can provide
instructionsdestructions if that'd be any help.
-
Install Nodejs, install Notepad++, done. And make sure NPM is installed, occasionally I've run into systems that have Node but not NPM.
If you're on Linux you'll need to run
sudo link -s /usr/bin/nodejs /usr/bin/node
because a billion years ago there used to be another program called node so nodejs refuses to use that, even though it requires its own executable to be named "node" for it to work.
-
Or you just run it using
nodejs
instead ofnode
. And yes, that does work.
-
npm
always seppukus during package installation if I don't do the symlink.
-
I'm not on the right system to check, but I get the feeling that's an environment variable issue rather than a symlink issue
-
npm always seppukus during package installation if I don't do the symlink.
I haven't had that experience on Kubuntu in the past.
Though the instructions I linked above get node from their site or repository or whatever instead of the defaults. I have 4.x instead of 0.10, so they avoid that and you end up with an executable
node
.
-
That could be the difference. Except for a couple times on the Raspberry Pi, I've always used whatever's in the distribution's repositories. I had to build node from source on the Pi once because their repo has an ancient version, and it took all day to build from source.
-
Well, like I said, until now, I've used whatever was in there and npm seemed to work just fine. But I wouldn't be surprised if some were better than others.
-
If you're on Linux you'll need to run
sudo link -s /usr/bin/nodejs /usr/bin/node
because a billion years ago there used to be another program called node so nodejs refuses to use that, even though it requires its own executable to be named "node" for it to work.Or you could do what Ubuntu seems to have done here:
pjh@pjh-thinkpad:~/src$ ls -l `which node nodejs` lrwxrwxrwx 1 root root 22 Dec 8 15:29 /usr/bin/node -> /etc/alternatives/node -rwxr-xr-x 1 root root 20376408 Mar 3 03:18 /usr/bin/nodejs pjh@pjh-thinkpad:~/src$ ls -l /etc/alternatives/node lrwxrwxrwx 1 root root 15 Mar 4 09:11 /etc/alternatives/node -> /usr/bin/nodejs pjh@pjh-thinkpad:~/src$
-
Or you could do what Ubuntu seems to have done here:
What version? This is what I get (Kubuntu 14.04):
$ ls -l `which node nodejs` -rwxr-xr-x 1 root root 1462424 Mar 27 2014 /usr/bin/nodejs
OTOH:
$ node The program 'node' can be found in the following packages: * node * nodejs-legacy
I only have nodejs (v0.10.25) installed from the default package manager. However, on my development VM, where I followed NodeBB's instructions, I have the same as you. But that also got me v4.4.0.
-
On my EC2 instance of Ubuntu 14.04.3 I get:
$ ls -l `which node nodejs` lrwxrwxrwx 1 root root 6 Mar 27 2014 /usr/bin/node -> nodejs -rwxr-xr-x 1 root root 1462424 Mar 27 2014 /usr/bin/nodejs
I think that version came from
apt-get
originally. It's also v0.10.25.I have
nvm
for newer versions of node for Sockbot things, but that installs to its own folder.
-
What version? This is what I get (Kubuntu 14.04):
Bog-standard Ubuntu 14.04:
pjh@pjh-thinkpad:~/src$ uname -a Linux pjh-thinkpad 3.19.0-43-generic #49~14.04.1-Ubuntu SMP Thu Dec 31 15:44:49 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux pjh@pjh-thinkpad:~/src$ cat /etc/issue Ubuntu 14.04.4 LTS \n \l
I only have nodejs (v0.10.25) installed from the default package manager. However, on my development VM, where I followed NodeBB's instructions, I have the same as you. But that also got me v4.4.0.
pjh@pjh-thinkpad:~/src$ node -v v4.3.2
Updated to latest nodebb on laptop yesterday and appeared to have acquired:
pjh@sofa:~/src/nodebb$ node -v v4.4.0
-
I believe that setup comes from:
$ cat /etc/apt/sources.list.d/nodesource.list deb https://deb.nodesource.com/node_4.x trusty main deb-src https://deb.nodesource.com/node_4.x trusty main
Not the standard Ubuntu sources. Following the guide to installing NodeBB on Ubuntu that I posted above, the first step does that with:
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
-
$ ./nodebb dev
indeed.
and if you want levels of logging you can set the
DEBUG
environmental variable to*
like so:DEBUG=* ./nodebb dev
-
pjh@pjh-thinkpad:~/src$ ls -l
which node nodejs
hmm.... i get something else entirely
accalia_de_elementia@sockdrawer:~/workspace/SockBot (feature-nodebb) $ ls -l `which node nodejs` -rwxr-xr-x 1 ubuntu ubuntu 25131267 Mar 9 02:51 /home/ubuntu/.nvm/versions/node/v5.8.0/bin/node* accalia_de_elementia@sockdrawer:~/workspace/SockBot (feature-nodebb) $
but then that is c9.io and i use nvm to install many versions of nodejs at the same time for testing
accalia_de_elementia@sockdrawer:~/workspace/SockBot (feature-nodebb) $ nvm ls iojs-v3.0.0 v0.10.40 v0.12.1 v0.12.10 v4.1.1 v5.3.0 v5.4.1 v5.6.0 -> v5.8.0 system default -> 5 (-> v5.8.0) node -> 5 (-> v5.8.0) stable -> 5.8 (-> v5.8.0) (default) unstable -> 5.3 (-> v5.3.0) (default) iojs -> iojs-v3.0 (-> iojs-v3.0.0) (default) accalia_de_elementia@sockdrawer:~/workspace/SockBot (feature-nodebb) $
-
-
@accalia said:
```
stable ->; 5.8 (-> v5.8.0) (default)
unstable -> 5.3 (-> v5.3.0) (default):wtf:</blockquote> nvm comes with several default aliases.... i don't get it either. the only alias i ever use is default every other time i switch version i switch to a version number explicitly.
-
OK, so I thought I'd have a look at the infiniscrolling on unread issue that's been mentioned. I followed the Cloud9 instructions (after installing another browser because Edge didn't show the second part of the captcha and just took me back to the sign up page), and realised I have no idea where to look for actually rendering the page. src/categories/unread.js seems to just be a few functions, not getting a list of unread.
Where do I start?
-
-
@Jaloopa so it worked for you? Ok, I'm either stupid or C9 is trolling me... Can you link to the instructions you used? Also, did you install NodeBB 1.0.0 or 1.0.1?
-
@Onyx We're now on 1.0.2. :-P
But for development, I'd think you'd want
master
. :trigger:
-
@boomzilla yeah, I'm getting a proper server sorted, but ran into a kinda wtf during the payment procedure so I don't know when that will be sorted... I at cave in and just set it up in VirtualBox like a proper pleb.
-
@Onyx said:
Can you link to the instructions you used?
The ones @RaceProUK linked at the top of this thread. It got to the point where I could run the forum instance and log in, so must have done something right
-
@Jaloopa Ah, they went with Mongo. I got stuck on that somewhere in what I found (seemed to be official instructions to me). Something about authentication IIRC.
Oh well, will give it a go then.
-
So...what about a NodeBB plugin development environment?
I was trying to make a plugin, modeled from an existing one. I had no idea how to deploy it, so I resorted to a symlink to the git repo. Which works, sort of. Of course, it means hard coding lots of stuff plus who knows what else.
The thing to do seems to be to use NodeBB Grunt:
OK, so that says you just use grunt. Well...how do I do that?
-
@boomzilla said:
grunt. Well...how do I do that?
DeathMetal Vocal tutorial 2: How to Guttural & Grunt – 10:44
— Alex Wenzel
-
@boomzilla said:
OK, so that says you just use grunt. Well...how do I do that?
Paging @Yamikuronue; she's got experience with it
-
@boomzilla said:
OK, so that says you just use grunt. Well...how do I do that?
npm install -g grunt-cli
installs the entry point. The project should havegrunt
and plugins in package.json, which all get installed with localnpm install
. After that you rungrunt <some-task>
and it reads the Gruntfile and does whatever.Try not to touch or look at the Gruntfile too hard, though. It might not be good for your sanity. Also it might break everything.
Alternative answer: carefully.
-
-
@Luhmann Guess who introduced me to Babymetal? ;)
-
@boomzilla I skipped all that, really. So far I got something working like this:
- created a new directory in
/path/to/nodebb/node_modules
namednodebb-plugin-pluginname
cd
'd into the directory, rannpm init
, filled out the data it asked for (left a few blank for now, too)- created a
plugin.json
file by grabbing the example from: https://docs.nodebb.org/en/latest/plugins/create.html and modifying it as needed - created a JS file which is basically something like this:
'use strict'; var Plugin = {}; Plugin.myMethod = function( ... ) { // do stuff here }; module.exports = Plugin;
where "myMethod" is whatever you defined method fields in
plugin.json
.
5. rannpm install
from NodeBB's root directory
6. started NodeBB with./nodebb dev
to get log messages printed to console
7. Once started, went to admin panel in NodeBB, activated my plugin, clicked "Reload Forum" in the dotburger menuThat loaded the plugin fine. It's not working properly yet, but at least it loads and triggers hooks properly.
- created a new directory in
-
@RaceProUK said:
Paging @Yamikuronue; she's got experience with it
You can tell from all the weeping and gnashing.
Of course, it's still better than the alternatives, so....
-
@Onyx said:
@boomzilla I skipped all that, really. So far I got something working like this:
I'm at a similar stage, except that I came across the following and used it:
It creates a bit more of the plugin scaffolding required.
-
More or less what I feared: I need to try and collect all the right components with roughly the right version and hope that everything on my end kinda-sorta resembles prod maybe if you squint just right.
I'm also guessing I will need to set up a VM for this since I'm running Windows 10.
Filed under: Thread Necromancy
-
@error said in How to set up a NodeBB dev environment:
I'm also guessing I will need to set up a VM for this since I'm running Windows 10
You shouldn't need to. It's not a bad idea to test it on a *nix just to sanity check your changes but node should work fine on Windows
-
It occurs to me that @apapadimoulis is missing a great opportunity to dogfood BuildMaster here. Some kind of pre-configured bundle that matches up to the actual server configuration would be great. Or any kind of CI at all...
-
I don't have a lot of experience in this, but I feel like we could really benefit from containerization of the development environment (you download a preconfigured image and just develop against that). This simultenously lowers the barrier to entry while also reducing variance between environments (which could manifest as bugs in delivered code).
I'm currently looking at Docker and Vagrant. I'm not really sure yet which is better suited. IIRC DickSores used Vagrant. I've heard a guiding principle for Git was "when in doubt, do the opposite of what CVS would do." I'm tempted to adopt a similar principle regarding Discourse, but I do think containers would be helpful here.
My first development goal is going to be to create a containerized dev environment to share with you.
-
@error said in How to set up a NodeBB dev environment:
IIRC DickSores used Vagrant.
They use docker. I know that @ben_lubar has docker set up for TDWTF.
I have no experience with those, though I was able to set stuff up pretty easily (as noted above) following the Ubuntu instructions. I'd also recommend getting an account over at community.nodebb.org and sharing stuff over there. It's also a handy resource.
-
@boomzilla I hope I'm not reinventing any wheels here. Maybe I need to align with @ben_lubar. I've got Vagrant up and running and so far it has a lot of promise.
The goal here is to have an instant buildup/teardown of an environment representing our specific customized setup, not a generic nodebb build. I want it to be as close as it can be to the actual production environment it's targeting. (I say this not knowing much about the actual environment it's running against.) If I can't achieve that, at the very least I want everyone on the development environment targetting the same versions of the same libraries on the same platforms etc.
Nodebb is very configurable. That's great for Nodebb. Our environment is a specialized degenerate subset of possible Nodebb configurations. We need a standard baseline.
-
- both redis and mongo (configure the forum using mongo and then add redis for sessions)
"port": [4567, 4568],
in config.json- nginx proxy isn't anything special
- iframely on port 8061, again, nothing special
- custom css/html
- a bunch of plugins:
- the default ones that come with NodeBB (markdown has Allow HTML enabled)
- nodebb-plugin-deny-moderator-access
- nodebb-plugin-emailer-amazon (@barisusakli's fork, not important for a local copy)
- nodebb-plugin-emoji-static
- nodebb-plugin-google-analytics
- nodebb-plugin-gravatar
- nodebb-plugin-htmlcleaner
- nodebb-plugin-iframely
- nodebb-plugin-imagemagick
- nodebb-plugin-import-tdwtf (the tdwtf branch of https://github.com/BenLubar/nodebb-plugin-import-discourse)
- nodebb-plugin-mentions-emoji
- nodebb-plugin-ns-login (for the front page)
- nodebb-plugin-shortcuts (most of them disabled, type ? on this forum to see the enabled shortcuts)
- nodebb-plugin-sso-facebook
- nodebb-plugin-sso-github
- nodebb-plugin-sso-google
- nodebb-plugin-sso-twitter
- nodebb-plugin-tdwtf-buttons
- nodebb-plugin-unresponsive
- nodebb-plugin-upvote-notifications
- nodebb-plugin-youtube-lite
- you can ask admins to take screenshots of settings pages if you can't guess the values. I'm not going to screenshot all of them right now, but the defaults are mostly sane.
-
My current status is stalled out on getting Vagrant/Docker to communicate with VirtualBox. Both of them report errors when trying to communicate with VBox. This is the quality I've come to expect from Oracle.
Also, Vagrant appears to be Ruby based (-10 points already), and the config file is also a Ruby script. I've installed two Vagrant plugins that looked useful, and neither one actually supports Windows. Also, to getvagrant ssh
to work, they recommend I install Cygwin? WTF? Damn it, the whole reason I'm trying to use this product is to make the dev stack platform agnostic!Probably going to give up and take @boomzilla's recommended approach of piecemeal development of individual components with no real way to integration test.
-
@error said in How to set up a NodeBB dev environment:
IIRC DickSores used Vagrant
I created a vagrantfile to launch dicksores without contaminating my machine, if that's what you're confused with.
-
@Yamikuronue said in How to set up a NodeBB dev environment:
@error said in How to set up a NodeBB dev environment:
IIRC DickSores used Vagrant
I created a vagrantfile to launch dicksores without contaminating my machine, if that's what you're confused with.
So that's how I got those!
Filed under: Genital herpes, Explaining the joke
-
@error said in How to set up a NodeBB dev environment:
My current status is stalled out on getting Vagrant/Docker to communicate with VirtualBox.
It's eaasy. Start by pushing your penis into a running food processor. If you don't have a food processor, try the waste disposal unit in your sink. If you don't have a penis, "tits in a mangle" springs to mind.