javascript - How can I put this code in an external file? -


i've made little chat nodejs, want put part of code https://github.com/p-pariston/nodechat/blob/698ced0afc77e359a2bd32618baf66a873241816/app.js#l112-402 (in yellow) in external file called commands.js.

actually, i've tested this:

app.js

command.prototype.parser = require('./commands.js'); 

commands.js

module.export = function (){...} 

it doesn't work, have:

"mongoclient not defined".

all modules not passed in commands.js can see (socket.io)

thanks !

it doesn't include context mongoclient has been set require @ top of first set of code (outside commands file)

mongoclient = require('mongodb').mongoclient,


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -