Let's say there is no intellisense for node packages in Visual studio code(Sometimes intellisense doesn't work properly for a package it can't intellisense some field in the package), how do you know what you can import ?
CodePudding user response:
You can search directly in the source code (in the node_modules folder there is a folder called as the package, find module.exports or export keywords) or check the documentation if there is one.
CodePudding user response:
You could get every key of the imported variable
const fs = require('fs');
console.log(Object.keys(module))
// ["writeFile","readdir","readdirSync",...]
Unless what's imported is a class for example when you'd have to get it's .prototype value. This will give you every function and property listed in the module exported object