christopherbalz
christopherbalz

Reputation: 730

How to specify current working directory for project-level `.npmrc`?

An absolute path, as shown below, works, but I need npm to use a relative path from the directory of the .npmrc file (the current working directory for the project), instead of the absolute path.

How to specify the relative path (instead of writing out the absolute path), or if it's not that simple, how to set things up?

Absolute path used in <some-project>/.npmrc:

onload-script = /some-absoloute-path/some-node-module.js

Upvotes: 3

Views: 3012

Answers (1)

Ortomala Lokni
Ortomala Lokni

Reputation: 62515

From the npmrc documentation:

Environment variables can be replaced using ${VARIABLE_NAME}. For example:

prefix = ${HOME}/.npm-packages

For your case, you can use the $PWD environment variable, which gives the current directory:

onload-script = ${PWD}/some-relative-path/some-node-module.js

Upvotes: 5

Related Questions