get-dev-paths

Search node_modules for locally developed packages

Usage no npm install needed!

<script type="module">
  import getDevPaths from 'https://cdn.skypack.dev/get-dev-paths';
</script>

README

get-dev-paths

Search node_modules for symlinks that resolve to a package outside any node_modules directories.

Returns an array of symlink paths that match the following criteria:

  • they live in node_modules
  • their real paths are not in node_modules
  • they are non-dev dependencies (as defined in package.json)

Every matched package also has its node_modules searched.

Scoped packages are supported.

New in v0.1.1: Up to 50x faster!

import getDevPaths from 'get-dev-paths';

// When called with one argument, an array is returned which contains symlink
// paths that match the required criteria.
let paths = getDevPaths(process.cwd());

// When you want an array of resolved symlinks, set `preserveLinks` to false:
paths = getDevPaths(__dirname, {
  preserveLinks: false,
});

// When the returned array is missing an expected package, you can use the
// `onError` option to inspect why a symlink was skipped.
paths = getDevPaths(__dirname, {
  onError: console.error,
});