Azure-pipelines-tasks: npm install fails ENOENT: no such file or directory (.staging directory)

Created on 23 Jan 2020  路  23Comments  路  Source: microsoft/azure-pipelines-tasks

Required Information

Type: Bug
Enter Task Name: npmV1

Environment

  • Server - Azure Pipelines

  • Agent - Hosted: Azure Pipeline / Hosted ubuntu 18.04

Issue Description

npm install fails on every build

Error logs

tasklog.txt

Artifacts aa-triaged bug

Most helpful comment

The "solutions" in anything I found online are not actually solutions

  • npm init doesn't solve the problem inside azure
  • Delete package-lock.json works but is a very weak workaround as the package-lock.json is an important file that shouldn't need to be deleted
  • rm -rf node_modules && npm cache clean --force also doesn't work
  • If you follow the other threads you can see that none of this solves the underlying problem, which is still undetected by anyone

It was working before, yes. Now it fails every time. I have now resorted to locking down versions inside the package.json but that defeats the purpose of having a lock file.

I agree that this is not an issue isolated to Azure DevOps pipelines, but even within the npm project this issue is completely unsolved.

All 23 comments

When deleting the package-lock.json the build works reliably without error. But that can hardly be the desired workaround as it completely defeats the purpose of having a lock file.

I've been directed to this issue by Microsoft support (issue 119121024001007) but I'm not sure it's related:

  1. npm ci
  2. npm ci --production
  3. DeleteFiles@1 fails with: Unhandled: Failed find: ENOENT: no such file or directory, stat '/home/vsts/work/1/s/node_modules/.bin/_mocha'

This started as Microsoft introduced Azure Functions v3 with support for Node 12, so with started pinpointing Node/npm versions using NodeTool@0:

  • Disabled = Default = 12.13.1/6.13.2 - Failed
  • ~10 = 10.18.1/6.13.4 - Failed
  • 10.17.0 = 10.17.0 /6.11.3 - OK!

Haven't investigated Node 12 versions yet...

This seems to be an NPM issue not a task issue:

https://github.com/WordPress/gutenberg/issues/9474

https://stackoverflow.com/questions/38143558/npm-install-resulting-in-enoent-no-such-file-or-directory

@flopes89 Can you try the suggested solutions and let me know? Also, was this working before and randomly started failing?

@christerengman I am not sure if it's related, it doesn't seem to be at this moment but I am still investigating.

The "solutions" in anything I found online are not actually solutions

  • npm init doesn't solve the problem inside azure
  • Delete package-lock.json works but is a very weak workaround as the package-lock.json is an important file that shouldn't need to be deleted
  • rm -rf node_modules && npm cache clean --force also doesn't work
  • If you follow the other threads you can see that none of this solves the underlying problem, which is still undetected by anyone

It was working before, yes. Now it fails every time. I have now resorted to locking down versions inside the package.json but that defeats the purpose of having a lock file.

I agree that this is not an issue isolated to Azure DevOps pipelines, but even within the npm project this issue is completely unsolved.

After troubleshooting with @stephenmichaelf we fixed our problem using npm prune --production instead of npm ci --production. Reason probably being that ci is asynchronous while prune is synchronous. Don't know if it helps you @flopes89 but might be valuable information for you and anyone else. :)

Thank you @stephenmichaelf !

@christerengman I'll sure give it a try

Having the same issue here enoent ENOENT: no such file or directory, open '/home/vsts/work/package.json' https://dev.azure.com/TrustWallet/Assets/_build/results?buildId=19868&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=bd05475d-acb5-5619-3ccb-c46842dbc997 package.json and package-lock.json are checked in repo.
Tried: npm install via Task and -script, npm ci, node 10.x, 11.x, 12.x

@christerengman Aren't npm ci and npm prune doing completely different things? npm ci installs versioned packages in package-lock.json to node_modules while npm prune removes packages from node_modules?

any fix for this, we are also experiencing the problem?

same issue here.....every once in a while it fails

I'm having same issue different error (see below). It works if I delete package-lock.json but as of yesterday my builds started building different so I decided to include package-lock.json again to see if it would resolve it but this came up.

error code EINTEGRITY
error sha1-zsDyXALIIS7WvG3n7w54QAmEhs0= integrity checksum failed when using sha1: wanted sha1-zsDyXALIIS7WvG3n7w54QAmEhs0= but got sha512-ZUEcjQIMvD1I/nXBDWZY5szciMk83aWvDtyUonD8QMEuvPAiX1ViZH9IgrSJAtOlr3bdm3O6wlWKHUHSBS7F+Q== sha1-Cp0zDcOS+rDj13WkI1i7zUOrpNk=

Hi Team, We are facing this randomly on our VSTS hosted agent today. This is the final error message we get

19681 error code ENOENT
19682 error syscall spawn git
19683 error path git
19684 error errno ENOENT
19685 error enoent Error while executing:
19685 error enoent undefined ls-remote -h -t ssh://[email protected]/eligrey/FileSaver.js.git
19685 error enoent
19685 error enoent
19685 error enoent spawn git ENOENT
19686 error enoent This is related to npm not being able to find a file.
19687 verbose exit [ 1, true ]

##[debug]Agent.BuildDirectory=C:\agent\_work\2
##[debug]rm -rf C:\agent\_work\2\npm
##[debug]removing directory
##[debug]task result: Failed
##[error]Error: Npm failed with return code: 1

HOLY SHIT, After 2 hours of reading various threads back and forth this answer fixed my issue.

@gethari did you only add .npmignore file only ? because that doesn't solve my issue. The error is same.

@gethari did you only add .npmignore file only ? because that doesn't solve my issue. The error is same.

@himanshush13 It did resolve the issue for time being for one or two days. Today we are facing this issue again ! 馃槦

UPDATE

I don't know if this is the right solution. I downgraded Angular CLI to 8.3.23 and it did resolved my issue, and also we were using a build step called NODE we removed it and installed node directly on the server

Hi,

Are you still experiencing this issue?

Thanks

@omokoh Sure. i am currently experiencing same issue from my end.

Updating to npm 7 solved the issue for me

Updating to npm 7 solved the issue for me

Same for me as well.

Experiencing this issue as well. @ssensegar or @PaulVrugt what exact version of npm 7? And were you installing that in your dev environment or somehow forcing the pipeline agent to use npm 7?

@alexweininger installing npm7 locally doesn't make sense since the error occurs in the pipeline. You can install npm7 during the pipeline process by using the following task before any npm command:


  - task: Npm@1
    displayName: 'Install npm 7'
    inputs:
      command: 'custom'
      workingDir: $(Build.Repository.LocalPath)
      verbose: false
      customCommand: 'i -g npm@next-7'

@PaulVrugt Thanks, I just tried adding that to my .yml and that task fails with the following error:

941 verbose stack Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/abbrev'
942 verbose cwd /home/vsts/work/1/s
943 verbose Linux 5.4.0-1032-azure
944 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-g" "npm@next-7"
945 verbose node v14.15.1
946 verbose npm  v6.14.9
947 error code EACCES
948 error syscall access
949 error path /usr/local/lib/node_modules/npm/node_modules/abbrev
950 error errno -13
951 error Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/abbrev'
951 error  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/abbrev'] {
951 error   errno: -13,
951 error   code: 'EACCES',
951 error   syscall: 'access',
951 error   path: '/usr/local/lib/node_modules/npm/node_modules/abbrev'
951 error }

I'm not sure what's happening here.

Was this page helpful?
0 / 5 - 0 ratings