.npmrc
这是 rush init 为单仓库 .npmrc 文件生成的模板
common/config/rush/.npmrc
# Rush uses this file to configure the NPM package registry during installation. It is applicable
# to PNPM, NPM, and Yarn package managers. It is used by operations such as "rush install",
# "rush update", and the "install-run.js" scripts.
#
# NOTE: The "rush publish" command uses .npmrc-publish instead.
#
# Before invoking the package manager, Rush will copy this file to the folder where installation
# is performed. The copied file will omit any config lines that reference environment variables
# that are undefined in that session; this avoids problems that would otherwise result due to
# a missing variable being replaced by an empty string.
#
# * * * SECURITY WARNING * * *
#
# It is NOT recommended to store authentication tokens in a text file on a lab machine, because
# other unrelated processes may be able to read the file. Also, the file may persist indefinitely,
# for example if the machine loses power. A safer practice is to pass the token via an
# environment variable, which can be referenced from .npmrc using ${} expansion. For example:
#
# //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
#
registry=https://registry.npmjs.org/
always-auth=false
.npmrc 文件优先级
常规 Rush 操作执行以下查找
- 为了支持不寻常的情况,NPM 配置环境变量优先于任何 .npmrc 设置。环境变量名称以
npm_config_
为前缀。例如,设置npm_config_registry
变量将覆盖 .npmrc 中的registry
设置。NPM 设计接受诸如npm_config_@example:registry
之类的非标准名称模式。 - 通常,设置来自 Rush 复制到工作目录的临时 .npmrc 文件。该文件从 common/config/rush/.npmrc 复制而来,但省略了引用未定义环境变量的任何行(如上所述)。对于大多数操作,工作目录将是 common/temp。
- 如果包管理器无法通过 1 或 2 找到设置,则会咨询用户的 ~/.npmrc。单个用户通常在此文件中存储其身份验证令牌。
上述规则也适用于 install-run.js 等辅助脚本。
rush publish
命令使用不同的文件 .npmrc-publish,它有自己的规则。有关详细信息,请参见 此文档。
如果直接调用包管理器(而不是通过 Rush),则上述规则不适用。例如,从 shell 调用 npm publish
,然后将应用 包管理器的通常优先级。通常不鼓励在 Rush 仓库中执行此操作,但如果使用,则可能需要创建其他 .npmrc 文件。