【发布时间】:2016-05-01 16:20:45
【问题描述】:
我已经使用 Azure VM 和 Azure 上的 Visual Studio Release 插件设置了 VSO 代理。我还安装了最新版本的 node.js(使用 NVM for windows)。我在安装 VSO 代理时使用了默认帐户,因为我用于远程桌面的凭据不起作用。
我可以远程进入机器并运行我试图从 VSO 运行的构建脚本。我也可以使用它运行纯粹的 .NET 构建,而且效果很好。我的问题在于使用 npm 安装我的包并运行构建。
我已经对构建提出了这样的要求:
npm | exists
我已经通过控制面板在 VSO 代理上设置了一项功能,如下所示:
npm | C:\Program Files\nodejs\npm.cmd
也试过
npm | C:\Program Files\nodejs
我可以在该文件夹中看到 npm.cmd,并且可以在远程使用该路径时运行 npm。我还根据这个问题重新启动了 VSO 代理服务:
TFS build agent cannot locate npm
重新启动服务器并多次“更新所有代理”。我的路径中也有 npm,登录后可以正常执行。
编辑:
错误信息:
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\work-folder\1\s\azure-deploy.ps1:24 char:1
+ npm update
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我也尝试过添加如下所述的行:
$env:Path += ";C:\Program Files\nodejs\"
同样的错误。在该命令给出之后,我的 $env:Path 的 Write-Host 写入:
C:\Application Intallers\agent (1)\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Internal\NativeBinaries\amd64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Users\propertyplotdev\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI\wbin;C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy;C:\Program Files\nodejs;C:\Windows\ServiceProfiles\LocalService\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin;C:\Windows\ServiceProfiles\LocalService\.dnx\bin;C:\Program Files\nodejs\
C:\Program Files\nodejs\npm.cmd 和 C:\Program Files\nodejs\node.js 都存在并且 NETWORK SERVICE 对它们具有权限。 (以及管理员、SYSTEM 和我的登录名)
【问题讨论】:
-
使用 npm 任务对构建进行排队时会收到什么错误消息?
-
@Eddie-MSFT 在我的问题中添加了错误消息
-
我刚刚遇到了这个问题。事实证明,如果您重新启动代理服务,代理将自动选择节点和 npm 作为功能。无需手动添加。
标签: node.js azure npm azure-devops azure-pipelines