find-npm-prefix

WebJar for find-npm-prefix

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

find-npm-prefix
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

find-npm-prefix
WebJar for find-npm-prefix
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/npm/find-npm-prefix

Download find-npm-prefix

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/find-npm-prefix/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>find-npm-prefix</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/find-npm-prefix/
implementation 'org.webjars.npm:find-npm-prefix:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/find-npm-prefix/
implementation ("org.webjars.npm:find-npm-prefix:1.0.2")
'org.webjars.npm:find-npm-prefix:jar:1.0.2'
<dependency org="org.webjars.npm" name="find-npm-prefix" rev="1.0.2">
  <artifact name="find-npm-prefix" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='find-npm-prefix', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "find-npm-prefix" % "1.0.2"
[org.webjars.npm/find-npm-prefix "1.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

find-npm-prefix

Find the npm project directory associated with for a given directory

USAGE

const findPrefix = require('find-npm-prefix')

findPrefix(process.cwd()).then(prefix => {
  …
})

findPrefix(dir) → Promise(prefix)

This computes the npm prefix, that is, the directory that npm adds and removes modules from for a given path.

It takes a directory as an argument and returns a promise of the associated prefix directory.

Algorithm

  1. If the directory is a node_modules folder, scan up the tree till you find a non-node_modules directory and return that.
  2. Else, look for the first parent directory that contains a node_modules or a package.json
  3. If one is found, that's the prefix.
  4. If none are found, return the original directory we were given
org.webjars.npm

npm

node package manager

Versions

Version
1.0.2