Azure DevOps - npm 不可见

Azure DevOps - npm invisible

我对 Azure DevOps 中的发布管道有一个奇怪的问题。

我有两个任务:

1) 安装包

2) 运行 npm 使用上述包

一切看起来都很简单所以我做的是:

1) 命令行任务

npm install -g mkdirp 1.0.3
npm install -g newman
npm install -g newman-reporter-junitfull

2) PowerShell 任务

   $(newman run $collection -e $environment --env-var "x=$(x)" -r junit --reporter-junit-export $resultFile) 

直到今天,这一切都运行良好。我尝试了很多,但没有任何效果。

我的错误是:

newman : The term 'newman' 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.

有人遇到过类似的问题吗?

我运行在命令行任务中执行 npm install scripts,发现只执行了第一个 npm install 命令。我对 运行 newman 命令的以下 powershell 任务也失败并显示上述错误消息。您可以检查命令行任务的日志,看看它是否是同一个问题。

如果你想报告这个问题,你可以报告一个问题here

我找到的解决方法是 运行 在 Powershell 任务中执行 npm install 命令,不要使用命令行任务。然后 npm install 命令将全部执行,下面的 powershell 任务可以 运行 成功。

或者你可以将以上三个npm install命令分成三个命令行任务分别安装,这样就可以确保newman库已经安装好了。