我已将我的项目配置为通过 .npmrc 文件使用私有 Azure DevOps 源。
我有一个执行以下操作的 .js 脚本:
const { exec } = require('child_process');
const npmrc_location = ...
const commands =
[
'npm install vsts-npm-auth --registry https://registry.npmjs.com --always-auth false --no-save',
'vsts-npm-auth -R -C ' + npmrc_location
];
exec(commands.join('&&'), (error) => {
if (error) {
console.log(error)
}});
Run Code Online (Sandbox Code Playgroud)
当它第一次在 $env:USERPROFILE.npmrc 文件下创建 .npmrc 文件时,一切都很好。
文档说,如果 -F 标志“不存在或为假,则目标配置文件中的现有令牌只有在接近或过期时才会被替换”。所以重新运行脚本作为我项目构建步骤的一部分应该没问题。
但是,有时我在'vsts-npm-auth -R -C ' + npmrc_location'执行时遇到以下错误:
Run Code Online (Sandbox Code Playgroud)vsts-npm-auth v0.41.0.0: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters..
我最好的猜测是它尝试读取 .npmrc 文件的内容。
有谁知道为什么会发生这种情况以及什么是好的解决方案?
谢谢
Ahm*_*gdy 28
我想你之前可能已经运行过 vsts-npm-auth 并且在你的主目录的 .npmrc 中隐藏了令牌,它不再有效,你可能会尝试使用 -F 来强制获取新令牌。
| 归档时间: |
|
| 查看次数: |
3137 次 |
| 最近记录: |