Ionic 找不到模块'@schematics/angular/utility/project'

nwlls2ji  于 2022-12-08  发布在  Ionic
关注(0)|答案(8)|浏览(134)

If I do ionic generate component xxx
An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project' Require stack:

  • /Users/user/develop/myapp/node_modules/@ionic/angular-toolkit/schematics/component/index.js
  • /Users/user/develop/myapp/node_modules/@angular-devkit/schematics/tools/export-ref.js
  • /Users/user/develop/myapp/node_modules/@angular-devkit/schematics/tools/index.js
  • /Users/user/develop/myapp/node_modules/@angular/cli/utilities/json-schema.js
  • /Users/user/develop/myapp/node_modules/@angular/cli/models/command-runner.js
  • /Users/user/develop/myapp/node_modules/@angular/cli/lib/cli/index.js
  • /Users/user/develop/myapp/node_modules/@angular/cli/lib/init.js
  • /Users/user/develop/myapp/node_modules/@angular/cli/bin/ng

Ionic:

Ionic CLI                     : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
 Ionic Framework               : @ionic/angular 5.2.3
 @angular-devkit/build-angular : 0.1000.2
 @angular-devkit/schematics    : 10.0.2
 @angular/cli                  : 10.0.2
 @ionic/angular-toolkit        : 2.2.0

Capacitor:

Capacitor CLI   : 2.1.2
 @capacitor/core : 2.1.2

Cordova:

Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
 Cordova Platforms : android 8.1.0
 Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 7 other plugins)

Utility:

cordova-res : not installed
 native-run  : not installed

System:

ios-sim : 8.0.2
 NodeJS  : v12.18.1 (/usr/local/bin/node)
 npm     : 6.14.6
 OS      : macOS Catalina
 Xcode   : Xcode 11.5 Build version 11E608c
idv4meu8

idv4meu81#

看起来像是离子不相容
这对我很有效

npm uninstall @schematics/angular
npm install @schematics/angular@9.1.0
dy2hfwbg

dy2hfwbg2#

您可以首先在schematics/angular上执行npm uninstall,TERMINAL会通知您“已删除XX个软件包并审核XXXX个软件包”等,然后您可以在schematics/angular@9.1.0上执行npm install。
相应地,ng add ngx-bootstrap提供了:
添加️了“ Bootstrap
添加️了“ngx Bootstrap

ygya80vv

ygya80vv3#

在我的情况下,这是有:

"@ionic/angular-toolkit": "^2.3.3"

而不是“^2.2.0”
我的Angular :10.1.4。
我发现这一点后,创建新的离子项目升级离子CLI最新。

ivqmmu1c

ivqmmu1c4#

The problem is schematics module incompatibility.

  1. Find out the version of the @schematics/angular
node_modules/@schematics/angular/package.json/#_from
  1. Find out the version of @schematics/angular which used in the @ionic/angular-toolkit module.
node_modules/@ionic/angular-toolkit/package.json

// package.json 

"dependencies": {
    "@schematics/angular": "^11.2.4",  
}
  1. Make sure the versions are matching.
  2. If the versions do not match, then install the matching version of @schematics/angular.
  3. Have an awesome day!
f3temu5u

f3temu5u5#

请尝试以下代码

npm install @angular-devkit/schematics @angular-devkit/core @schematics/angular
chhkpiq4

chhkpiq46#

这对我很有效。

npm i --save-dev @nativescript/schematics
ltqd579y

ltqd579y8#

你能试着运行ng add @angular/pwa@13吗?

相关问题