https://github.com/jchip/node-module-dir
Find the top dir of a package in node_modules
https://github.com/jchip/node-module-dir
Last synced: 3 months ago
JSON representation
Find the top dir of a package in node_modules
- Host: GitHub
- URL: https://github.com/jchip/node-module-dir
- Owner: jchip
- Created: 2021-04-21T17:12:54.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-21T21:55:30.000Z (about 5 years ago)
- Last Synced: 2024-10-29T20:01:33.755Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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`.
```js
const { findNodeModuleDir } = require("node-module-dir");
const dir = findNodeModuleDir("package-name");
```
# License
Licensed under the [Apache License, Version 2.0]
[apache license, version 2.0]: https://www.apache.org/licenses/LICENSE-2.0