发生未处理的异常:不支持关键字“id”,请使用“$ id”作为模式ID。

10

运行ng deploy时,我收到以下错误:

An unhandled exception occurred: NOT SUPPORTED: keyword "id", use "$id" for schema ID
See "C:\Users\theoh\AppData\Local\Temp\ng-Nv0wMh\angular-errors.log" for further details.

错误的完整日志如下:

[error] Error: NOT SUPPORTED: keyword "id", use "$id" for schema ID
    at Object.code (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\vocabularies\core\id.js:6:15)
    at keywordCode (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\validate\index.js:454:13)
    at D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\validate\index.js:222:17
    at CodeGen.code (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\codegen\index.js:439:13)
    at CodeGen.block (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\codegen\index.js:568:18)
    at iterateKeywords (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\validate\index.js:219:9)
    at groupKeywords (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\validate\index.js:208:13)
    at D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\validate\index.js:192:13
    at CodeGen.code (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\codegen\index.js:439:13)
    at CodeGen.block (D:\code\brain-consulting\bbc\node_modules\@angular\cli\node_modules\ajv\dist\compile\codegen\index.js:568:18)

我按照这里建议的尝试使用ng add @angular-eslint/schematics@next,但它没有起作用。我使用的版本如下:

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.3
@angular-devkit/build-angular   13.0.3
@angular-devkit/core            13.0.3
@angular-devkit/schematics      13.0.3
@angular/cli                    13.0.3
@angular/fire                   7.0.2
@nguniversal/builders           13.0.1
@nguniversal/express-engine     13.0.1
@schematics/angular             13.0.3
rxjs                            6.6.7
typescript                      4.4.4

有什么建议吗?

4个回答

7

我也遇到了同样的问题。在我的情况下,这是由于 ng update 期间未更新 @angular-builders/custom-webpack 导致的。手动将其从版本 10.0.1 更新到 ^13.0.0 可以解决问题。


2
在我的Angular项目中,当我尝试创建一个像这样的服务:
ng g s folder-name/folder-name/service-name

我从Angular CLI得到了这个错误。

An unhandled exception occurred: NOT SUPPORTED: keyword "id", use "$id" for schema ID
See "/private/var/folders/fw/5mkxql_j6c33ssny9wj1w1g80000gn/T/ng-ixUrL3/angular-errors.log" for further details.

因此,我在运行CLI命令时不使用别名s - services,而是像这样使用全名。
ng generate service folder-name/folder-name/service-name

我在CLI命令中再次尝试,对我有效。希望这个技巧也能帮到您。

是的,这对我也有效...但是有些不对劲。像“ng g c something”这样的简短版本应该可以工作 :( - Itay
是的,没错。简短版本应该可以工作。我正在尝试找出为什么它不起作用。可能是Angular CLI问题或错误。 - shehan96
我找到了我的错误 - 我使用了一个名为Akita的状态管理包 - 它带有自己的cli命令 - 我升级了它,问题得到了解决! - Itay

0
尝试删除 package-lock 文件“如果可以安全地这样做”,以及 node modules 文件夹。然后在 package.json 文件中更改 "jasmine-core": "~3.6.0" 为 "jasmine-core": "~3.8.0" 然后运行 npm install。 这对我有用。

有更新/升级软件包的命令。 - Sebastian Scholle

0

这是我为解决这个问题所做的步骤:

  • 删除 package-lock.json 文件
  • 使用 npm install 命令
  • 执行 npm update 命令

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接