Thanks a lot. This should save me loads of time! 🙂
NodeBB libraries not accessible in plugin?
-
I'm trying to follow the basic tutorial on writing nodebb plugins.
But I'm using
module.parent.require('./database')
in my plugin but it isn't working.It simply says:
Error: Cannot find module './database'
Can anyone point me to the issue?
-
Where is your file located? The requre only works from a javascript file that is in the root of the plugin folder.
-
I'd suggest using
require.main.require('./src/database')
instead -
@pitaj Thanks! That worked!
Do you think the docs should be updated to include that?
-
@asamolion
module.parent.require
also works fine. It depends whether you are calling it from a dependent file, or from the main plugin library file. -
Also, just FYI, the docs you used are the old docs, the new ones are at docs.nodebb.org
You can open an issue at github.com/nodebb/docs if you wish for a change to be made