microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.46k stars 2.6k forks source link

[BUG]: Npm@1 node local prefix location appears to have changed #19200

Closed lukeschlather closed 4 months ago

lukeschlather commented 10 months ago

Task name

Npm

Task version

1

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu Latest

Task log

Previously npm local prefix was set to $(Agent.WorkFolder):

2023-10-26T18:32:25.5896384Z ; node bin location = /usr/local/bin/node
2023-10-26T18:32:25.5899376Z ; node version = v18.18.2
2023-10-26T18:32:25.5900319Z ; npm local prefix = /home/vsts/work
2023-10-26T18:32:25.5901047Z ; npm version = 9.8.1
2023-10-26T18:32:25.5901484Z ; cwd = /home/vsts/work/1/s
2023-10-26T18:32:25.5902022Z ; HOME = /home/vsts
2023-10-26T18:32:25.5902937Z ; Run `npm config ls -l` to show all defaults.
2023-10-26T18:32:25.5905755Z [command]/usr/local/bin/npm install handlebars

Now without a change to our pipeline yaml it's set to $(System.DefaultWorkingDirectory).

2023-10-30T22:22:49.7411308Z ; node bin location = /usr/local/bin/node
2023-10-30T22:22:49.7411816Z ; node version = v18.18.2
2023-10-30T22:22:49.7412289Z ; npm local prefix = /home/vsts/work/1/s
2023-10-30T22:22:49.7412734Z ; npm version = 9.8.1
2023-10-30T22:22:49.7413087Z ; cwd = /home/vsts/work/1/s
2023-10-30T22:22:49.7413417Z ; HOME = /home/vsts
2023-10-30T22:22:49.7414011Z ; Run `npm config ls -l` to show all defaults.
2023-10-30T22:22:49.7508597Z [command]/usr/local/bin/npm install handlebars

Additional info

This results in the node module being installed to a different location which breaks other tasks which rely on this one. We were able to fix this by changing workingDir from System.DefaultWorkingDirectory to Agent.WorkFolder. However it seems like there was an (unintentional?) breaking change to Npm@1.

   - task: Npm@1
     displayName: Install Handlebars
     inputs:
       command: 'custom'
-      workingDir: '$(System.DefaultWorkingDirectory)'
+      workingDir: '$(Agent.WorkFolder)'
       customCommand: 'install handlebars'
github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days