Skip to content

Instantly share code, notes, and snippets.

@RohitRox

RohitRox/dep.js

Created Jun 30, 2020
Embed
What would you like to do?
Find installed version of package dependencies
// $ node dep.js
var fs = require("fs");
function main() {
var packageJsonFile = "package.json";
var packageData = JSON.parse(fs.readFileSync(packageJsonFile));
console.log("devDependencies:");
Object.keys(packageData.devDependencies).forEach(function (f) {
var d = JSON.parse(fs.readFileSync("node_modules/"+f+"/package.json"));
console.log('"' + d.name + '": "' + d.version + '",');
});
console.log("dependencies:");
Object.keys(packageData.dependencies).forEach(function (f) {
var d = JSON.parse(fs.readFileSync("node_modules/" + f + "/package.json"));
console.log('"' + d.name + '": "' + d.version + '",');
});
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.