10

context

NPM version : 8.9.4
npm version : 6.9.0

We are using azure devops build pipelines with windows vs2017 hosted agents

problem

every ~ 1 in 10 builds Fails with the following error:

error

verbose stack SyntaxError: Unexpected end of JSON   input while parsing near '...st":{"integrity":"sha' 

18263 verbose stack     at JSON.parse (<anonymous>)  

18263 verbose stack     at parseJson (C:\npm\prefix\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)  

18263 verbose stack     at consumeBody.call.then.buffer (C:\npm\prefix\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50)
18263 verbose stack     at <anonymous>  

18263 verbose stack     at process._tickCallback (internal/process/next_tick.js:188:7)  

the JSON it cant parse varies.

Things I have already tried

  • use npm ci instead op npm install

  • have a build task that removes the npm chache before the npm install. (npm cache clean --force)

  • have a build task that changes the used registery. (config set registry "https://registry.npmjs.com/")

CIPan
  • 101
  • 5
  • 3
    We get the same thing but not quite as regular as you. When it does go it can take lots of rebuilds to get it to work again! :( Did you ever resolve this? – caveman_dick Aug 20 '19 at 10:52
  • Did you ever resolve this? We get this a lot the last few weeks – devqon Sep 04 '20 at 07:27
  • Same here - getting this quite regularly every couple of builds. Some solutions suggest running "npm cache clean --force" but this doesn't solve/help – Adriaan de Beer Dec 15 '20 at 00:52
  • Just started randomly getting this yesterday. Today it's like 1 out of 5 builds pass. Looks like the problem child is with json-parse-better-errors package. The error message is always different but it's always complaining about trying to parse json in their readme file. – mwilson May 12 '22 at 18:46

1 Answers1

0

If 9 out of 10 builds are succeeding, perhaps the problem isn't in your npm cache, perhaps it's your build workspace. Have you tried adding this to your build pipeline at the start of your job steps?

jobs:
- job:
  workspace:
    clean: all
  # ... other job settings
  steps:
  # ... build steps
WaitingForGuacamole
  • 3,744
  • 1
  • 8
  • 22