[英]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. 如下所示,可以使用绝对路径,但是我需要
npm
才能使用.npmrc
文件目录(项目的当前工作目录)中的相对路径,而不是绝对路径。
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
: <some-project>/.npmrc
使用的绝对路径:
onload-script = /some-absoloute-path/some-node-module.js
From the npmrc documentation : 从npmrc文档中 :
Environment variables can be replaced using ${VARIABLE_NAME}.
可以使用$ {VARIABLE_NAME}替换环境变量。 For example:
例如:
prefix = ${HOME}/.npm-packages
For your case, you can use the $PWD
environment variable, which gives the current directory: 对于您的情况,可以使用
$PWD
环境变量,该变量提供当前目录:
onload-script = ${PWD}/some-relative-path/some-node-module.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.