以下错误仅在DevOps管道上的Npm@1个任务期间发生.这款应用程序在本地构建得很好.一点错误都没有.
ANGLE CLI版本为8.3.29,打字版本为3.5.3.
它正在执行这个定制命令:
run build:artifact
而该自定义命令在package.json
中指向以下内容:
ng build --configuration=artifact
抛出的错误是:
../node_modules/@types/lodash/common/lang.d.ts:577:74-错误TS2677: 类型谓词的类型必须可分配给其参数的类型.
管道中的完整日志(log):
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! project-angular@0.0.0 build:artifact: `ng build --configuration=artifact`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project-angular@0.0.0 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
> project-angular@0.0.0 build:artifact D:\a\1\s\client-site-spa
> ng build --configuration=artifact
您知道如何查找引发此错误的位置吗?
当我用匹配的node\npm版本在我的dev box上手动运行相同的命令[ng build --configuration=artifact
]时,没有发生错误:
####
在按照MikeOne的建议删除了node_modules
文件夹和package-lock.json
文件后,我能够从本地管道中得到相同的错误...然而,它仍然没有告诉我们错误是在哪个文件中发生的.:___
####
没有迹象表明这个错误在我自己的源代码中的任何地方发生.这会是lodash
本身的错误吗?我使用的是最新的版本,现在是4.17.21.
####
这似乎是TypeScrip编译器一直在抱怨的接口成员……但是,我不会在代码中的任何地方调用它.