Plugin development: environment setup
-
Hello plugin developers,
Please, share your experience: how do you develop plugins for NodeBB?
- Do you use git-submodules?
- Do you use npm link?
- Do you use unix links?
- Do you use separate nodebb setup per versioned plugin?
-
It's been a while since it got an update, but I still use my nodebb-grunt-development to create and modify my plugins (written in coffeescript).
Using one NodeBB setup for all plugins, can't see any reason not to do...
-
I suck so I copy/pasta a general structure I currently use in my plugins into a new folder and npm link that into one big messy NodeBB install.
One of these days I'll do it properly and I'll use something similar to grunt with maybe TypeScript, possibly in combination with Vagrant. One of these days...
-
After some work with npm link I have found, that links do not fit NodeBB development (Main problem, that you should reuse NodeBB modules, it looks like this (../../../src/topics) and It does not work Ok with linked modules, of course you could use parent-require solution with try-catches, but I don't like such approach)
So my development is based on File Watchers (reusable solution). I have extended
plugin.json
to provide syncing path, and every plugin is in separate project/repository, file watchers just sync plugins -
@Nicolas I can't find the topic or post right now but you really should use
require.parent
or even betterrequire.main
when using NodeBB modules. Path traversal is scary and error prone.require.main
will beapp.js
, so you can dorequire.main.require('./src/{module_name}')
and it'll work everytime.I usually solve this like this.
-
Yes, as @Schamper recommends, do not use relative paths to break out of the plugin's root directory, just use
module.parent.require
to require from the context ofplugins.js
, orrequire.main.require
to require from the context ofapp.js
To answer OP, I use
npm link
to link my folders together. I have one big messy NodeBB install ( ) and next to it is aplugins/
folder where all the plugins live.@psychobunny integrated grunt into NodeBB, so I just use
grunt --verbose
to develop now, instead of./nodebb dev