Azure DevOps build pipeline - npm ci - Unexpected end of JSON input

Viewed 2796

I have Azure DevOps build pipeline configured to build NPM application, that includes the following tasks:

  1. Install Node.js (Node.js tool installer) - Version Spec 10.x
  2. npm ci (npm task)

And it almost always fails on the npm ci task, with error:

SyntaxError: Unexpected end of JSON input while parsing near ' and then some random string, each time different.

enter image description here

If I re-run the job manually, it will works. Then, at the next build, it fails again (until I manually rerun it again).

I am also using Azure Artifacts feed with configured Upstream sources to https://registry.npmjs.org/ and npm ci task is configured to use packages from this registry.

enter image description here

I have tried to:

  1. remove Artifacts feed and create a new one
  2. remove Install Node.js task
  3. change node version
  4. change npm ci to npm install

and nothing works. How else can I fix that?

EDIT - 03 April 2020

Here is my package.json - I've removed some of the private data. There are two private packages, @project-name/jodit-vue and @project-name/vuex-orm-plugin-axios hosted on Azure Artifacts - those are forks of jodit-vue and vuex-orm-plugin-axios with some customizations.

Also, less builds failed recently. About one in 8 builds fails now.

{
  "name": "name",
  "version": "1.0.0",
  "private": true,
  "scripts": {

  },
  "dependencies": {
    "@project-name/jodit-vue": "^1.2.4-fix",
    "@project-name/vuex-orm-plugin-axios": "0.5.0",
    "@stomp/stompjs": "^5.4.2",
    "@vuex-orm/core": "^0.33.0",
    "axios": "^0.19.0",
    "chart.js": "^2.9.3",
    "chartjs-plugin-colorschemes": "^0.4.0",
    "core-js": "^3.4.8",
    "crypto-js": "^3.1.9-1",
    "drag-drop-touch": "^1.3.0",
    "emoji-mart-vue-fast": "^6.1.2",
    "file-saver": "^2.0.2",
    "jquery": "^3.4.0",
    "lodash": "^4.17.14",
    "moment": "^2.24.0",
    "oidc-client": "^1.9.1",
    "shepherd.js": "^5.0.1",
    "vue": "^2.6.10",
    "vue-chartjs": "^3.5.0",
    "vue-class-component": "^7.1.0",
    "vue-cookie-law": "^1.8.0",
    "vue-cropperjs": "^4.0.0",
    "vue-i18n": "^8.15.1",
    "vue-matomo": "^3.13.0-0",
    "vue-property-decorator": "^8.3.0",
    "vue-recaptcha": "^1.3.0",
    "vue-router": "^3.1.3",
    "vue-stripe-elements-plus": "^0.2.8",
    "vuejs-logger": "^1.5.3",
    "vuetify": "^1.5.21",
    "vuex": "^3.1.2",
    "vuex-oidc": "^3.3.1",
    "xlsx": "^0.15.2"
  },
  "devDependencies": {
    "@babel/core": "^7.7.5",
    "@babel/plugin-transform-runtime": "^7.7.6",
    "@babel/preset-env": "^7.7.6",
    "@babel/preset-typescript": "^7.7.4",
    "@kazupon/vue-i18n-loader": "^0.4.1",
    "@storybook/addon-actions": "^5.3.13",
    "@storybook/addon-docs": "^5.3.13",
    "@storybook/addon-knobs": "^5.3.13",
    "@storybook/addon-links": "^5.3.13",
    "@storybook/addon-viewport": "^5.3.13",
    "@storybook/vue": "^5.3.13",
    "@types/chai": "^4.1.6",
    "@types/crypto-js": "^3.1.43",
    "@types/file-saver": "^1.3.1",
    "@types/jquery": "^2.0.47",
    "@types/lodash": "^4.14.119",
    "@types/mocha": "^2.2.46",
    "@types/sinon": "^7.0.13",
    "@types/stripe": "^5.0.24",
    "@types/stripe-v3": "^3.0.8",
    "@types/webpack": "^4.4.14",
    "@types/webpack-env": "^1.13.6",
    "@vue/cli": "^4.1.1",
    "@vue/cli-plugin-babel": "^4.1.1",
    "@vue/cli-plugin-eslint": "^4.1.2",
    "@vue/cli-plugin-pwa": "^4.1.1",
    "@vue/cli-plugin-typescript": "^4.1.1",
    "@vue/cli-plugin-unit-jest": "^4.1.1",
    "@vue/cli-plugin-unit-mocha": "^4.1.1",
    "@vue/cli-service": "^4.1.1",
    "@vue/eslint-config-typescript": "^4.0.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-loader": "^8.0.6",
    "babel-plugin-transform-imports": "^2.0.0",
    "chai": "^4.2.0",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "moment-locales-webpack-plugin": "^1.1.2",
    "node-sass": "^4.13.0",
    "react": "^16.12.0",
    "react-is": "^16.12.0",
    "sass-loader": "^8.0.0",
    "sinon": "^7.4.1",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "typescript": "^3.7.4",
    "vue-cli-plugin-i18n": "^0.6.0",
    "vue-cli-plugin-storybook": "^1.2.0",
    "vue-cli-plugin-vuetify": "^2.0.2",
    "vue-jest": "^3.0.4",
    "vue-loader": "^15.7.1",
    "vue-template-compiler": "^2.6.10"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

SOLVED (partially) - 15 April 2020

I have changed npm ci to npm install a few days ago. No more fails, every build finished successfully since this change. install is slower that ci but we can spend one more minute in each build but be sure that it will not fail.

0 Answers
Related