We have problem with our build pipeline for npm install
below is an excerpt from the log. This error happens quite frequently but not every time. Thus I've tried to solve it by running 2nd Attempt task when 1st failed, but this doesn't solve this error. It happens only on Azure pipeline, npm install
run locally works...
This is a TypeScript React app that is built on the azure pipeline.
2020-03-26T10:38:16.6609188Z ##[section]Starting: npm install 2nd Attempt
2020-03-26T10:38:16.6788267Z ==============================================================================
2020-03-26T10:38:16.6788382Z Task : npm
2020-03-26T10:38:16.6788466Z Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
2020-03-26T10:38:16.6788532Z Version : 1.165.0
2020-03-26T10:38:16.6788593Z Author : Microsoft Corporation
2020-03-26T10:38:16.6788672Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/npm
2020-03-26T10:38:16.6788736Z ==============================================================================
2020-03-26T10:38:17.2859304Z SYSTEMVSSCONNECTION exists true
2020-03-26T10:38:17.8968387Z SYSTEMVSSCONNECTION exists true
2020-03-26T10:38:18.3178413Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C "C:\temp\_work\_tool\node\8.17.0\x64\npm.cmd --version"
2020-03-26T10:38:19.5417276Z 6.13.4
2020-03-26T10:38:19.5546292Z SYSTEMVSSCONNECTION exists true
2020-03-26T10:38:19.6804593Z SYSTEMVSSCONNECTION exists true
2020-03-26T10:38:22.0732149Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C "C:\temp\_work\_tool\node\8.17.0\x64\npm.cmd config list"
2020-03-26T10:38:23.2654131Z ; cli configs
2020-03-26T10:38:23.2654913Z metrics-registry = "https://MyCompany.pkgs.visualstudio.com/_packaging/MyCompany-Artifacts/npm/registry/"
2020-03-26T10:38:23.2655225Z scope = ""
2020-03-26T10:38:23.2655510Z user-agent = "npm/6.13.4 node/v8.17.0 win32 x64"
2020-03-26T10:38:23.2655752Z
2020-03-26T10:38:23.2656000Z ; environment configs
2020-03-26T10:38:23.2656265Z userconfig = "C:\\temp\\_work\\4\\npm\\12184.npmrc"
2020-03-26T10:38:23.2656536Z
2020-03-26T10:38:23.2656848Z ; project config C:\temp\_work\4\s\.npmrc
2020-03-26T10:38:23.2657206Z always-auth = true
2020-03-26T10:38:23.2657545Z registry = "https://MyCompany.pkgs.visualstudio.com/_packaging/MyCompany-Artifacts/npm/registry/"
2020-03-26T10:38:23.2657994Z
2020-03-26T10:38:23.2658276Z ; node bin location = C:\temp\_work\_tool\node\8.17.0\x64\node.exe
2020-03-26T10:38:23.2658527Z ; cwd = C:\temp\_work\4\s
2020-03-26T10:38:23.2658728Z ; HOME = C:\Users\sysadmin
2020-03-26T10:38:23.2658967Z ; "npm config ls -l" to show all defaults.
2020-03-26T10:38:23.2659419Z
2020-03-26T10:38:23.2668324Z [command]C:\WINDOWS\system32\cmd.exe /D /S /C "C:\temp\_work\_tool\node\8.17.0\x64\npm.cmd install --no-optional"
...
2020-03-26T10:40:29.4831279Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\number\is-integer\shim.js'
2020-03-26T10:40:29.4831530Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\number\is-nan\shim.js'
2020-03-26T10:40:29.4831641Z npm WARN [email protected] requires a peer of jest@>=20 <=24 but none is installed. You must install peer dependencies yourself.
2020-03-26T10:40:29.4831748Z npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
2020-03-26T10:40:29.4831844Z npm WARN [email protected] requires a peer of react@~0.14.8 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
2020-03-26T10:40:29.4831964Z npm WARN [email protected] requires a peer of react-dom@~0.14.8 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
2020-03-26T10:40:29.4832050Z npm WARN The package devtron is included as both a dev and production dependency.
2020-03-26T10:40:29.4832156Z npm WARN The package electron-devtools-installer is included as both a dev and production dependency.
2020-03-26T10:40:29.4832225Z
2020-03-26T10:40:29.4832458Z npm ERR! Unexpected end of JSON input while parsing near '...ents/code/npm/man/man'
2020-03-26T10:40:29.4832557Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\number\is-safe-integer\shim.js'
2020-03-26T10:40:29.4832671Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\object\assign\shim.js'
2020-03-26T10:40:29.4832770Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\object\entries\shim.js'
2020-03-26T10:40:29.4832867Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\object\keys\shim.js'
...
2020-03-26T10:40:29.5685813Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\iterable\validate.js'
2020-03-26T10:40:29.5685897Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\iterable\validate.js'
2020-03-26T10:40:29.5686017Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\promise\.eslintrc.json'
2020-03-26T10:40:29.5686284Z npm WARN tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\promise\.eslintrc.json'
2020-03-26T10:40:29.5686347Z
2020-03-26T10:40:29.5686418Z npm ERR! A complete log of this run can be found in:
2020-03-26T10:40:29.5686499Z npm ERR! C:\Users\sysadmin\AppData\Roaming\npm-cache\_logs\2020-03-26T10_40_26_002Z-debug.log
2020-03-26T10:40:29.5694378Z Found npm debug log, make sure the path matches with the one in npm's output: C:\Users\sysadmin\AppData\Roaming\npm-cache\_logs\2020-03-26T10_40_26_002Z-debug.log
2020-03-26T10:40:29.5694810Z 8004 silly decomposeActions build [email protected]
2020-03-26T10:40:29.5695055Z 8005 silly decomposeActions install [email protected]
2020-03-26T10:40:29.5695256Z 8006 silly decomposeActions postinstall [email protected]
2020-03-26T10:40:29.5695498Z 8007 silly decomposeActions finalize [email protected]
...
2020-03-26T10:40:29.7045575Z 18555 warn tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\math\sinh\shim.js'
2020-03-26T10:40:29.7045685Z 18556 warn tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\math\tanh\shim.js'
2020-03-26T10:40:29.7046044Z 18557 warn tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\math\trunc\shim.js'
2020-03-26T10:40:29.7046198Z 18558 warn tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\number\is-finite\shim.js'
2020-03-26T10:40:29.7046311Z 18559 warn tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\number\is-integer\shim.js'
2020-03-26T10:40:29.7046648Z 18560 warn tar ENOENT: no such file or directory, open 'C:\temp\_work\4\s\node_modules\.staging\es5-ext-01671651\test\number\is-nan\shim.js'
2020-03-26T10:40:29.7048565Z 18561 verbose unlock done using C:\Users\sysadmin\AppData\Roaming\npm-cache\_locks\staging-be6c2a9d7e735ae4.lock for C:\temp\_work\4\s\node_modules\.staging
2020-03-26T10:40:29.7049239Z 18562 timing stage:rollbackFailedOptional Completed in 4ms
2020-03-26T10:40:29.7049393Z 18563 timing stage:runTopLevelLifecycles Completed in 117228ms
2020-03-26T10:40:29.7049514Z 18564 silly saveTree [email protected]
2020-03-26T10:40:29.7049594Z 18564 silly saveTree +-- @types/[email protected]
2020-03-26T10:40:29.7049906Z 18564 silly saveTree +-- @types/[email protected]
2020-03-26T10:40:29.7050068Z 18564 silly saveTree | `-- @types/[email protected]
2020-03-26T10:40:29.7050147Z 18564 silly saveTree +-- @types/[email protected]
2020-03-26T10:40:29.7050220Z 18564 silly saveTree +-- @types/[email protected]
...
2020-03-26T10:40:29.7913586Z 18569 warn The package devtron is included as both a dev and production dependency.
2020-03-26T10:40:29.7913833Z 18570 warn The package electron-devtools-installer is included as both a dev and production dependency.
2020-03-26T10:40:29.7914064Z 18571 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ents/code/npm/man/man'
2020-03-26T10:40:29.7914343Z 18571 verbose stack at JSON.parse (<anonymous>)
2020-03-26T10:40:29.7914606Z 18571 verbose stack at parseJson (C:\temp\_work\_tool\node\8.17.0\x64\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
2020-03-26T10:40:29.7914922Z 18571 verbose stack at consumeBody.call.then.buffer (C:\temp\_work\_tool\node\8.17.0\x64\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50)
2020-03-26T10:40:29.7915178Z 18571 verbose stack at <anonymous>
2020-03-26T10:40:29.7919986Z 18571 verbose stack at process._tickCallback (internal/process/next_tick.js:189:7)
2020-03-26T10:40:29.7920359Z 18572 verbose cwd C:\temp\_work\4\s
2020-03-26T10:40:29.7920619Z 18573 verbose Windows_NT 10.0.18362
2020-03-26T10:40:29.7920908Z 18574 verbose argv "C:\\temp\\_work\\_tool\\node\\8.17.0\\x64\\node.exe" "C:\\temp\\_work\\_tool\\node\\8.17.0\\x64\\node_modules\\npm\\bin\\npm-cli.js" "install" "--no-optional"
2020-03-26T10:40:29.7923019Z 18575 verbose node v8.17.0
2020-03-26T10:40:29.7923275Z 18576 verbose npm v6.13.4
2020-03-26T10:40:29.7923540Z 18577 error Unexpected end of JSON input while parsing near '...ents/code/npm/man/man'
2020-03-26T10:40:29.7923796Z 18578 verbose exit [ 1, true ]
2020-03-26T10:40:29.7927345Z
2020-03-26T10:40:29.7944531Z ##[error]Error: Npm failed with return code: 1
You can either commit a . npmrc file to your source code repository and set its path or select a registry from Azure Artifacts. Select this option to use feeds specified in a . npmrc file you've checked into source control.
7.0.0 • Public • Published 2 months ago.
Delete package-lock.json file and re run your pipeline
REMOVE NPM from your custom script command arguments
Azure pipeline task PREPENDS NPM Already ...
Full explanation:
when using the NPM task in Azure pipelines the task itself prepends npm.cmd which is equivalent to the 'npm' command in npm scripts.
This is a bit unusual since most script begin with npm, but the reason custom tasks have failed is because entering a custom task beginning with the npm command, will cause it to fail, as the azure pipeline task is already running it,
thus the custom task command arguments should exclude the initial npm command which is normally prepended on many tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With