这个问题可能看起来很愚蠢,但就像两周前一样,我在安装它时没有任何问题。现在看起来是这样的:

ng add @ngx-formly/schematics --ui-theme=material
我尝试在material和cdk模块之前/之后安装它,但结果是相同的。我还尝试安装所有独立的formly模块(基于我之前创建的项目),得到以下错误:
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.我还尝试删除节点模块和yarn.lock,并再次初始化它,但仍然不起作用。而且,当我创建表单时,它也没有显示出来。我也试着用yarn add安装它。或者-ui-主题=bootstrap,但结果是相同的。在安装它之前,我也尝试过ng serve (在堆栈上的某个地方读到它),但它也不能工作。
我听说node v.15.6.0有一些问题,但我不确定是不是这样。下面是我的版本:

纱线版本为1.22.5
更新:我尝试用yarn Update --latest升级所有的包,然后再次正式安装。在此之后:
ng add @ngx-formly/schematics --ui-theme=material我明白了:
An unhandled exception occurred: Cannot find module '@schematics/angular/utility/config'
Require stack:
- /home/wiktor/angular-material-template/node_modules/@ngx-formly/schematics/utils/ast.js
- /home/wiktor/angular-material-template/node_modules/@ngx-formly/schematics/src/ng-add/index.js
- /home/wiktor/angular-material-template/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /home/wiktor/angular-material-template/node_modules/@angular-devkit/schematics/tools/index.js
- /home/wiktor/angular-material-template/node_modules/@angular/cli/utilities/json-schema.js
- /home/wiktor/angular-material-template/node_modules/@angular/cli/models/command-runner.js
- /home/wiktor/angular-material-template/node_modules/@angular/cli/lib/cli/index.js
- /usr/lib/node_modules/@angular/cli/lib/init.js
- /usr/lib/node_modules/@angular/cli/bin/ng
See "/tmp/ng-rRKl9j/angular-errors.log" for further details.发布于 2021-01-26 09:34:25
好了,我找到解决方案了。我不得不将angular schematics降级到以前的版本(为了安全起见,我降级了两个版本):
npm uninstall @schematics/angular
npm install @schematics/angular@9.1.0因此,formly schematics与angular 11 schematics不兼容。
https://stackoverflow.com/questions/65894531
复制相似问题