Search code examples
azure-pipelinesnode-gyp

node-gyp rebuild fails on vsts hosted machine


When executing npm install on VSTS hosted machine, node-gyp rebuild fails for contextify package.

2017-11-09T00:16:37.9310105Z d:\a\1\s\Client\node_modules\contextify>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild ) 
2017-11-09T00:16:39.2998078Z gyp ERR! configure error 
2017-11-09T00:16:39.3018079Z gyp ERR! stack Error: Python executable "C:\Program Files\Python36\python.EXE" is v3.6.2, which is not supported by gyp.
2017-11-09T00:16:39.3028072Z gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at failPythonVersion (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:14)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:443:9
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at ChildProcess.exithandler (child_process.js:197:7)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at emitTwo (events.js:106:13)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:334:11)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at emitOne (events.js:96:13)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at Socket.emit (events.js:188:7)
2017-11-09T00:16:39.3028072Z gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:498:12)

The machine is Hosted VS2017. node-gyp requires python 2.7 and VS2015 build tools installed.

Is node-gyp supported on VSTS hosted machines or do I have to maintain my own build machine ?

Build definition (I've removed identifying strings)

    {
  "options": [
    {
      "enabled": false,
      "definition": {
        "id": "5d58cc01-7c75-450c-be18-a388ddb129ec"
      },
      "inputs": {
        "branchFilters": "[\"+refs/heads/*\"]",
        "additionalFields": "{}"
      }
    },
    {
      "enabled": false,
      "definition": {
        "id": "a9db38f9-9fdc-478c-b0f9-464221e58316"
      },
      "inputs": {
        "workItemType": "60151",
        "assignToRequestor": "true",
        "additionalFields": "{}"
      }
    },
    {
      "enabled": false,
      "definition": {
        "id": "57578776-4c22-4526-aeb0-86b6da17ee9c"
      },
      "inputs": {}
    }
  ],
  "variables": {
    "system.debug": {
      "value": "false",
      "allowOverride": true
    }
  },
  "retentionRules": [
    {
      "branches": [
        "+refs/heads/*"
      ],
      "artifacts": [],
      "artifactTypesToDelete": [
        "FilePath",
        "SymbolStore"
      ],
      "daysToKeep": 10,
      "minimumToKeep": 1,
      "deleteBuildRecord": true,
      "deleteTestResults": true
    }
  ],
  "_links": {
    "self": {
      "href": "<link here>"
    },
    "web": {
      "href": "<link here>"
    },
    "editor": {
      "href": "<link here>"
    }
  },
  "comment": "test",
  "jobAuthorizationScope": 1,
  "jobTimeoutInMinutes": 60,
  "jobCancelTimeoutInMinutes": 5,
  "process": {
    "phases": [
      {
        "dependencies": [],
        "steps": [
          {
            "environment": {},
            "enabled": true,
            "continueOnError": false,
            "alwaysRun": false,
            "displayName": "ClientLibraries npm install",
            "timeoutInMinutes": 0,
            "condition": "succeeded()",
            "refName": "Npm1",
            "task": {
              "id": "fe47e961-9fa8-4106-8639-368c022d43ad",
              "versionSpec": "1.*",
              "definitionType": "task"
            },
            "inputs": {
              "command": "install",
              "workingDir": "Client",
              "verbose": "false",
              "customCommand": "",
              "customRegistry": "useNpmrc",
              "customFeed": "",
              "customEndpoint": "",
              "publishRegistry": "useExternalRegistry",
              "publishFeed": "",
              "publishEndpoint": ""
            }
          },
          {
            "environment": {},
            "enabled": true,
            "continueOnError": false,
            "alwaysRun": false,
            "displayName": "Client gulp ",
            "timeoutInMinutes": 0,
            "condition": "succeeded()",
            "refName": "Gulp3",
            "task": {
              "id": "b82cfbe4-34f9-40f5-889e-c8842ca9dd9d",
              "versionSpec": "0.*",
              "definitionType": "task"
            },
            "inputs": {
              "gulpFile": "Client/gulpfile.js",
              "targets": "",
              "arguments": "",
              "cwd": "",
              "gulpjs": "node_modules/gulp/bin/gulp.js",
              "publishJUnitResults": "false",
              "testResultsFiles": "**/TEST-*.xml",
              "testRunTitle": "",
              "enableCodeCoverage": "false",
              "testFramework": "Mocha",
              "srcFiles": "",
              "testFiles": "test/*.js"
            }
          },
          {
            "environment": {},
            "enabled": true,
            "continueOnError": false,
            "alwaysRun": false,
            "displayName": "SharedApp npm install",
            "timeoutInMinutes": 0,
            "condition": "succeeded()",
            "refName": "Npm2",
            "task": {
              "id": "fe47e961-9fa8-4106-8639-368c022d43ad",
              "versionSpec": "1.*",
              "definitionType": "task"
            },
            "inputs": {
              "command": "install",
              "workingDir": "SharedApp",
              "verbose": "false",
              "customCommand": "",
              "customRegistry": "useNpmrc",
              "customFeed": "",
              "customEndpoint": "",
              "publishRegistry": "useExternalRegistry",
              "publishFeed": "",
              "publishEndpoint": ""
            }
          },
          {
            "environment": {},
            "enabled": true,
            "continueOnError": false,
            "alwaysRun": false,
            "displayName": "SharedApp gulp ",
            "timeoutInMinutes": 0,
            "condition": "succeeded()",
            "refName": "Gulp4",
            "task": {
              "id": "b82cfbe4-34f9-40f5-889e-c8842ca9dd9d",
              "versionSpec": "0.*",
              "definitionType": "task"
            },
            "inputs": {
              "gulpFile": "SharedApp/gulpfile.js",
              "targets": "",
              "arguments": "",
              "cwd": "",
              "gulpjs": "node_modules/gulp/bin/gulp.js",
              "publishJUnitResults": "false",
              "testResultsFiles": "**/TEST-*.xml",
              "testRunTitle": "",
              "enableCodeCoverage": "false",
              "testFramework": "Mocha",
              "srcFiles": "",
              "testFiles": "test/*.js"
            }
          },
          {
            "environment": {},
            "enabled": true,
            "continueOnError": false,
            "alwaysRun": false,
            "displayName": "Build MPos",
            "timeoutInMinutes": 0,
            "condition": "succeeded()",
            "refName": "MSBuild5",
            "task": {
              "id": "c6c4c611-aa2e-4a33-b606-5eaba2196824",
              "versionSpec": "1.*",
              "definitionType": "task"
            },
            "inputs": {
              "solution": "MPos/MPos.jsproj",
              "msbuildLocationMethod": "version",
              "msbuildVersion": "latest",
              "msbuildArchitecture": "x86",
              "msbuildLocation": "",
              "platform": "",
              "configuration": "",
              "msbuildArguments": "",
              "clean": "false",
              "maximumCpuCount": "false",
              "restoreNugetPackages": "false",
              "logProjectEvents": "false",
              "createLogFile": "false"
            }
          }
        ],
        "variables": {},
        "name": "Build",
        "target": {
          "demands": [
            "npm"
          ],
          "executionOptions": {
            "type": 0
          },
          "allowScriptsAuthAccessOption": false,
          "type": 1
        },
        "jobAuthorizationScope": "projectCollection",
        "jobCancelTimeoutInMinutes": 1
      }
    ],
    "type": 1
  },
  "repository": {
    "properties": {
      "cleanOptions": "3",
      "labelSources": "0",
      "labelSourcesFormat": "$(build.buildNumber)",
      "reportBuildStatus": "true",
      "gitLfsSupport": "false",
      "skipSyncSource": "false",
      "checkoutNestedSubmodules": "false",
      "fetchDepth": "0"
    },
    "id": "62d6c3ab-a240-4391-ab84-8bf922ce7c82",
    "type": "TfsGit",
    "name": "<name here>",
    "url": "<link here>",
    "defaultBranch": "refs/heads/freedom",
    "clean": "true",
    "checkoutSubmodules": false
  },
  "processParameters": {},
  "quality": 1,
  "authoredBy": {
    "id": "36711d94-f137-45f1-8948-8d025a1d344d",
    "displayName": "<My name>",
    "uniqueName": "<my email>",
    "url": "<link here>",
    "imageUrl": "<link here>"
  },
  "drafts": [],
  "queue": {
    "id": 343,
    "name": "Hosted VS2017",
    "pool": {
      "id": 118,
      "name": "Hosted VS2017",
      "isHosted": true
    }
  },
  "id": 13963,
  "name": "<name>",
  "url": "<link here>",
  "uri": "vstfs:///Build/Definition/13963",
  "path": "\\Retail",
  "type": 2,
  "queueStatus": 0,
  "revision": 3,
  "createdDate": "2017-11-09T00:15:07.623Z",
  "project": {
    "id": "2bdc3060-cc75-4bb4-8e85-9ce981e841fa",
    "name": "<name>",
    "url": "<link here>",
    "state": "wellFormed",
    "revision": 288029,
    "visibility": 1
  }
}

Solution

  • Python 2.7.13 is available at this location:C:\Python27amd64 on Hosted 2017 Agent. However, VS2015 build tools is not installed on that agent. So you have to use Hosted Agent rather than Hosted 2017 Agent to run this build.