The following error is happening only during Npm@1 task on the DevOps pipeline. The app builds just fine locally. No errors at all.
Angular CLI version is 8.3.29 and TypeScript version is 3.5.3.
It's executing this custom command:
run build:artifact
and that custom command points to this in package.json
:
ng build --configuration=artifact
The error being thrown is:
../node_modules/@types/lodash/common/lang.d.ts:577:74 - error TS2677: A type predicate's type must be assignable to its parameter's type.
Full log from the pipeline:
Starting: Angular Build
==============================================================================
Task : npm
Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version : 1.202.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.15.0\x64\npm.cmd --version"
6.14.8
C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.15.0\x64\npm.cmd config list"
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v14.15.0 win32 x64"
; environment configs
prefix = "C:\\npm\\prefix"
userconfig = "D:\\a\\1\\npm\\11507.npmrc"
; globalconfig C:\npm\prefix\etc\npmrc
cache = "C:\\npm\\cache"
; node bin location = C:\hostedtoolcache\windows\node\14.15.0\x64\node.exe
; cwd = D:\a\1\s\client-site-spa
; HOME = C:\Users\VssAdministrator
; "npm config ls -l" to show all defaults.
C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\node\14.15.0\x64\npm.cmd run build:artifact"
ERROR in ../node_modules/@types/lodash/common/lang.d.ts:577:74 - error TS2677: A type predicate's type must be assignable to its parameter's type.
Type 'EmptyObjectOf<T>' is not assignable to type 'T'.
'EmptyObjectOf<T>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'object'.
Type 'EmptyObject<T>' is not assignable to type 'T'.
'EmptyObject<T>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'object'.
577 isEmpty<T extends object>(value: T | null | undefined): value is EmptyObjectOf<T> | null | undefined;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:artifact: `ng build --configuration=artifact`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:artifact script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache\_logs\2022-08-17T15_41_17_869Z-debug.log
> [email protected] build:artifact D:\a\1\s\client-site-spa
> ng build --configuration=artifact
Do you know how to hunt down where this error is being thrown?
When I run the same command [ ng build --configuration=artifact
] manually on my dev box with matching node\npm versions, no error happens:
#######
After deleting the node_modules
folder and package-lock.json
file as MikeOne suggested, I was able to get the same error from the pipeline locally... however it still doesn't tell us in what file the error is happening. :|
#######
There's no indication this error is happening anywhere on my own source code. Would this be an error from lodash
itself? I'm using the latest version available as of now
#######
This seems to be the interface member that the TypeScript compiler is barking about... however, I'm not calling it anywhere on my code.
CodePudding user response:
A recent commit has broken the package. The issue is being tracked on their Github, but in the meantime we could stick to the previous version of @types/lodash
which is 4.14.182
.