node-module-dir

1.0.0 • Public • Published

node-module-dir

Find the top dir of a package in node_modules by looking for the first dir that contains package.json file. The search stops when it reaches the dir node_modules.

Normally this is just Path.dirname(require.resolve(name + "/package.json")), but new node.js and package.json ES module export blocks requiring package.json.

const { findNodeModuleDir } = require("node-module-dir");

const dir = findNodeModuleDir("package-name");

License

Licensed under the Apache License, Version 2.0

Readme

Keywords

Package Sidebar

Install

npm i node-module-dir

Weekly Downloads

0

Version

1.0.0

License

Apache-2.0

Unpacked Size

2.78 kB

Total Files

3

Last publish

Collaborators

  • jchip