UNPKG

@rockpack/compiler

Version:

The easiest webpack config generator.

23 lines (18 loc) 563 B
const finder = require('find-package-json'); const fs = require('node:fs'); const path = require('node:path'); const getNodeModules = (root) => { const f = finder(root); const packages = []; let packageJSON = f.next(); while (!packageJSON.done) { const currentPath = path.dirname(packageJSON.filename); const nodeModulesPath = path.resolve(currentPath, 'node_modules'); if (fs.existsSync(nodeModulesPath)) { packages.push(nodeModulesPath); } packageJSON = f.next(); } return packages; }; module.exports = getNodeModules;