简体   繁体   中英

How to list node_modules folders in a json/javascript file?

I want to introduce the dependencies I have in a d3.js tree and I was wondering if there is any way I can list the dependencies name dynamically in a json file or into the javascript file itself. I don't understand how javascript can read into folder names without external help. I do not wish to use any outside dependencies or server-side javascript.

In your package.json you have all the dependencies of your project and each dependency has its own package.json at the end there is a tree of dependencies that is built,

you can access the package.json with a simple

var package = require ('./path/package.json');

console.log(package.devDependencies);
console.log(package.dependencies);

i hope i have answered your question :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM