6

Azure VM と Azure 上の Visual Studio Release プラグインを使用して VSO エージェントをセットアップしました。node.js の最新バージョンもインストールしました (Windows 用の NVM を使用)。リモート デスクトップに使用した資格情報が機能しないため、VSO エージェントをインストールするときに既定のアカウントを使用しました。

マシンにリモート接続し、VSO から実行しようとしているビルド スクリプトを実行できます。また、それを使用して純粋に .NET ビルドを実行することもできます。私の問題は、npm を使用してパッケージをインストールし、ビルドを実行することにあります。

私は次のようにビルドに要求を設定しました:

npm | exists

次のように、コントロール パネルから VSO エージェントの機能を設定しました。

npm | C:\Program Files\nodejs\npm.cmd

も試しました

npm | C:\Program Files\nodejs

そのフォルダーに npm.cmd が表示され、そのパスを使用してリモートで npm を実行できます。この質問に従って、VSO Agent サービスも再起動しました。

TFS ビルド エージェントが 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\"

同じエラー。Write-Hostそのコマンドの後に私の $env:Path 書き込みの Aは次のようになります:

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 にはそれらに対する権限があります。(管理者、システム、および私のログインと同様に)

4

3 に答える 3

8

The solution to this was to install node.js with the regular installer :

https://nodejs.org/en/download/

This then worked. Still have other issues but the direct issue in this question is solved by not using nvm to install node. I could then add an npm task in the VSO build definition interface.

于 2016-01-27T00:19:12.667 に答える
3

npm が「C:\Program Files\nodejs\」フォルダーにインストールされていることを確認してから、PowerShell スクリプトに以下を追加します。

$env:Path += ";C:\Program Files\nodejs\"
于 2016-01-26T05:18:33.967 に答える
1

次からrun npm コマンドビルド タスクを追加してみてください。

ビルドステップを追加 -> タスクを追加 -> パッケージ -> npm (npm コマンドを実行)

installcommandとして追加し、web-projectのルートを作業ディレクトリとして追加します。

それ以外の場合は、次の機能を追加してみてください。

node.js | C:\Program Files\nodejs\node.exe

と:

   npm | C:\Program Files\nodejs\npm.cmd
于 2016-01-25T16:02:19.007 に答える