I've got error on running pipeline from exercise of learning path: Create a release pipeline in Azure Pipelines

성준 임 21 Reputation points
2022-01-28T02:30:57.933+00:00

I've got error on exercise of Learning path(https://learn.microsoft.com/en-us/learn/modules/create-release-pipeline/4-set-up-environment)

I'm a beginner just starting to learn about DevOps

I haven't modified anything, I've just followed the exercise

Error like follow


error------------------------------------------------------------------------------------------------------------------

Starting: Run npm install

==============================================================================

Task : npm
Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version : 1.198.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/npm

==============================================================================

/usr/local/bin/npm --version
8. 1.2
/usr/local/bin/npm config list
; "env" config from environment

userconfig = "/home/vsts/work/1/npm/45.npmrc"

; node bin location = /usr/local/bin/node
; cwd = /home/vsts/work/1/s
; HOME = /home/vsts
; Run npm config ls -l to show all defaults.
/usr/local/bin/npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated source-map-url@0.4.0: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated har-validator@5.1.3: this library is no longer supported
npm WARN deprecated source-map-resolve@0.5.2: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated chokidar@2.1.2: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path /home/vsts/work/1/s/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /home/vsts/work/1/s/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! make: Entering directory '/home/vsts/work/1/s/node_modules/node-sass/build'
.
.
.
.
.
.
.
2719 error ../src/binding.cpp: At global scope:
2719 error /home/vsts/.node-gyp/16.13.2/include/node/node.h:821:43: warning: cast between incompatible function types from ‘void ()(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void ()(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void ()(v8::Local<v8::Object>, v8::Local<v8::Value>, void)’} [-Wcast-function-type]
2719 error 821 | (node::addon_register_func) (regfunc), \
2719 error | ^
2719 error /home/vsts/.node-gyp/16.13.2/include/node/node.h:855:3: note: in expansion of macro ‘NODE_MODULE_X’
2719 error 855 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
2719 error | ^~~~~~~~~~~~~
2719 error ../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
2719 error 358 | NODE_MODULE(binding, RegisterModule);
2719 error | ^~~~~~~~~~~
2719 error make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
2719 error gyp ERR! build error
2719 error gyp ERR! stack Error: make failed with exit code: 2
2719 error gyp ERR! stack at ChildProcess.onExit (/home/vsts/work/1/s/node_modules/node-gyp/lib/build.js:262:23)
2719 error gyp ERR! stack at ChildProcess.emit (node:events:390:28)
2719 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
2719 error gyp ERR! System Linux 5.11.0-1027-azure
2719 error gyp ERR! command "/usr/local/bin/node" "/home/vsts/work/1/s/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
2719 error gyp ERR! cwd /home/vsts/work/1/s/node_modules/node-sass
2719 error gyp ERR! node -v v16.13.2
2719 error gyp ERR! node-gyp -v v3.8.0
2719 error gyp ERR! not ok
2719 error Build failed with error code: 1
2720 verbose exit 1

##[error]Error: Npm failed with return code: 1
Finishing: Run npm install


error------------------------------------------------------------------------------------------------------------------

Following is yml which provided by exercise that I used


trigger:    
- '*'    
    
pool:    
  vmImage: 'ubuntu-20.04'    
  demands:    
  - npm    
    
variables:    
  buildConfiguration: 'Release'    
  wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot'    
  dotnetSdkVersion: '5.x'    
    
steps:    
- task: UseDotNet@2    
  displayName: 'Use .NET SDK $(dotnetSdkVersion)'    
  inputs:    
    version: '$(dotnetSdkVersion)'  
    
- task: Npm@1    
  displayName: 'Run npm install'    
  inputs:    
    verbose: false  
    
- script: './node_modules/.bin/node-sass $(wwwrootDir) --output $(wwwrootDir)'    
  displayName: 'Compile Sass assets'    
    
- task: gulp@1    
  displayName: 'Run gulp tasks'    
    
- script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt'    
  displayName: 'Write build info'    
  workingDirectory: $(wwwrootDir)    
    
- task: DotNetCoreCLI@2    
  displayName: 'Restore project dependencies'    
  inputs:    
    command: 'restore'  
    projects: '**/*.csproj'  
    
- task: DotNetCoreCLI@2    
  displayName: 'Build the project - $(buildConfiguration)'    
  inputs:    
    command: 'build'  
    arguments: '--no-restore --configuration $(buildConfiguration)'  
    projects: '**/*.csproj'  
    
- task: DotNetCoreCLI@2    
  displayName: 'Publish the project - $(buildConfiguration)'    
  inputs:    
    command: 'publish'  
    projects: '**/*.csproj'  
    publishWebProjects: false  
    arguments: '--no-build --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)'  
    zipAfterPublish: true  
    
- publish: '$(Build.ArtifactStagingDirectory)'    
  artifact: drop    

How can I solve this problem?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,960 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Jaspreet Singh 6 Reputation points
    2022-03-31T02:53:50.663+00:00

    Add the following task before the npm task and it should work.

    • task: NodeTool@0
      displayName: 'Run Node install'
      inputs:
      versionSpec: '14.x'

    or

    • task: NuGetToolInstaller@0
      inputs:
      versionSpec: '5.9.1'

    I was struggling on the same step with multiple failed builds, but now it is working after adding the above step.

    Source: https://stackoverflow.com/questions/70208136/azure-devops-pipeline-npm-install-task-fails-with-node-gyp-build-error

    1 person found this answer helpful.