npm install package-exists --save
This is the solution for you!
package-exists
is a simple way to check if a node module is installed. Here is an example of how to use it:
var exists = require("package-exists");
if(exists.npmexists("package-exists")) {
console.log(true);
}else{
console.log(false);
}
That's it! Here is the detailed use of npmexists()
:
//returns true if package exists, false if it does not.
npmexists(package) //package is the name of the package to search for. No need to include ./node_modules/ it searches there automatically.