I\'m looking for a way to find out if a module is available.
For example, I want to check if the module mongodb is available, programmatically.
mongodb
ES6 simple solution with 1 line of code :
const path = require('path'); const fs = require('fs'); function hasDependency(dep) { return module.paths.some(modulesPath => fs.existsSync(path.join(modulesPath, dep))); }