• Home
Name Date Size #Lines LOC

..--

test/12-May-2024-8075

LICENSED12-May-2024734 1612

README.mdD12-May-2024798 2919

find-prefix.jsD12-May-20241.5 KiB5740

package.jsonD12-May-20241.6 KiB6362

README.md

1# find-npm-prefix
2
3Find the npm project directory associated with for a given directory
4
5## USAGE
6
7```
8const findPrefix = require('find-npm-prefix')
9
10findPrefix(process.cwd).then(prefix => {
1112})
13```
14
15## findPrefix(dir) → Promise(prefix)
16
17This computes the npm prefix, that is, the directory that npm adds and
18removes modules from for a given path.
19
20It takes a directory as an argument and returns a promise of the associated
21prefix directory.
22
23## Algorithm
24
251. If the directory is a `node_modules` folder, scan up the tree till you find a non-`node_modules` directory and return that.
262. Else, look for the first parent directory that contains a `node_modules` or a `package.json`
27  1. If one is found, that's the prefix.
28  2. If none are found, return the original directory we were given
29