首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Ionic build上出现Angular错误:找不到模块'@ionic/angular-toolkit/package.json‘

在Ionic build上出现Angular错误:找不到模块'@ionic/angular-toolkit/package.json‘
EN

Stack Overflow用户
提问于 2021-09-29 11:14:51
回答 1查看 1.6K关注 0票数 1

当我运行"ionic cordova build ios“时,当调用ng时,我得到以下错误:

代码语言:javascript
运行
复制
> ng run app:ionic-cordova-build:production --platform=ios
2021-09-29T09:57:54.068Z ng:analytics getGlobalAnalytics
2021-09-29T09:57:54.070Z ng:analytics Client Analytics config found: false
2021-09-29T09:57:54.070Z ng:analytics Analytics disabled. Ignoring all analytics.
2021-09-29T09:57:54.070Z ng:analytics getSharedAnalytics
An unhandled exception occurred: Cannot find module '@ionic/angular-toolkit/package.json'
Require stack:
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /Users/ralf/n/lib/node_modules/@angular/cli/models/architect-command.js
- /Users/ralf/n/lib/node_modules/@angular/cli/commands/run-impl.js
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /Users/ralf/n/lib/node_modules/@angular/cli/utilities/json-schema.js
- /Users/ralf/n/lib/node_modules/@angular/cli/models/command-runner.js
- /Users/ralf/n/lib/node_modules/@angular/cli/lib/cli/index.js
- /Users/ralf/n/lib/node_modules/@angular/cli/lib/init.js
- /Users/ralf/n/lib/node_modules/@angular/cli/bin/ng
See "/private/var/folders/y7/p3fxhqk92d30gbk09x6_w5480000gn/T/ng-wCJI7m/angular-errors.log" for further details.
[ERROR] An error occurred while running subprocess ng.

以下是"ionic info“的输出:

代码语言:javascript
运行
复制
Ionic:

   Ionic CLI                     : 6.16.3 (/Users/ralf/n/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.8.1
   @angular-devkit/build-angular : 12.2.7
   @angular-devkit/schematics    : 12.0.5
   @angular/cli                  : 12.0.5
   @ionic/angular-toolkit        : 4.0.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0, ios 5.0.1
   Cordova Plugins   : cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)

Utility:

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

System:

   ios-deploy : 1.9.2
   NodeJS     : v14.17.0 (/Users/ralf/n/bin/node)
   npm        : 7.21.1
   OS         : macOS Big Sur
   Xcode      : Xcode 13.0 Build version 13A233

我不知道这里出了什么问题。@ in /angular-toolkit/package.json可以在我的项目中找到。

任何关于如何解决这个问题的帮助都将不胜感激。

更新:添加了package.json

代码语言:javascript
运行
复制
{
  "name": "myApp_Phone",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-pwa": "ng build --base-href /",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ngcc"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.0.1",
    "@angular/common": "~12.0.1",
    "@angular/core": "~12.0.1",
    "@angular/fire": "^6.1.5",
    "@angular/forms": "~12.0.1",
    "@angular/platform-browser": "~12.0.1",
    "@angular/platform-browser-dynamic": "~12.0.1",
    "@angular/router": "~12.0.1",
    "@angular/service-worker": "~12.0.1",
    "@ckeditor/ckeditor5-angular": "^2.0.2",
    "@ckeditor/ckeditor5-build-classic": "^29.2.0",
    "@firebase/app": "^0.6.22",
    "@firebase/auth": "^0.16.6",
    "@firebase/polyfill": "^0.3.36",
    "@firebase/util": "^1.1.0",
    "@ionic-native/calendar": "^5.36.0",
    "@ionic-native/camera": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/facebook": "^5.36.0",
    "@ionic-native/fcm": "^5.36.0",
    "@ionic-native/file": "^5.36.0",
    "@ionic-native/file-opener": "^5.36.0",
    "@ionic-native/google-plus": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/ionic-webview": "^5.36.0",
    "@ionic-native/qr-scanner": "^5.36.0",
    "@ionic-native/social-sharing": "^5.36.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.36.0",
    "@ionic/angular": "^5.5.2",
    "@ionic/storage-angular": "^3.0.6",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "6.0.0",
    "angular2-uuid": "^1.1.1",
    "cordova-plugin-calendar": "^5.1.5",
    "cordova-plugin-camera": "^6.0.0",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-facebook4": "~6.4.0",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.8.0",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-opener2": "^3.0.5",
    "cordova-plugin-googleplus": "^8.5.2",
    "cordova-plugin-inappbrowser": "^5.0.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-qrscanner": "^3.0.1",
    "cordova-plugin-recentscontrol": "^1.1.2",
    "cordova-plugin-splashscreen": "^6.0.0",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-whitelist": "^1.3.5",
    "cordova-plugin-x-socialsharing": "^6.0.3",
    "cordova-sqlite-storage": "6.0.0",
    "core-js": "^3.12.1",
    "cropperjs": "^1.5.12",
    "firebase": "^8.6.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic4-auto-complete": "^2.9.9",
    "jwt-decode": "^3.1.2",
    "moment": "^2.29.1",
    "ngx-image-compress": "^11.0.3",
    "rxjs": "~6.6.7",
    "unorm": "^1.6.0",
    "xcode": "^3.0.1",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.0.1",
    "@angular/cli": "~12.0.1",
    "@angular/compiler": "~12.0.1",
    "@angular/compiler-cli": "~12.0.1",
    "@angular/language-service": "~12.0.1",
    "@ionic/angular-toolkit": "^4.0.0",
    "@ionic/lab": "^3.2.10",
    "@types/jasmine": "~3.9.1",
    "@types/jasminewd2": "~2.0.10",
    "@types/jwt-decode": "^2.2.1",
    "@types/node": "~16.10.1",
    "codelyzer": "^6.0.2",
    "cordova-android": "^9.1.0",
    "es6-promise-plugin": "^4.2.2",
    "jasmine-core": "~3.9.0",
    "jasmine-spec-reporter": "~7.0.0",
    "karma": "~6.3.4",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.7.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.2.4"
  },
  "description": "Fortunella myApp Phone",
  "cordova": {
    "plugins": {
      "cordova-plugin-qrscanner": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-camera": {
        "ANDROIDX_CORE_VERSION": "1.6.+"
      },
      "cordova-plugin-recentscontrol": {},
      "cordova-plugin-facebook4": {
        "APP_ID": "367618343602117",
        "APP_NAME": "Fortunella App",
        "ANDROID_SDK_VERSION": "4.+",
        "FACEBOOK_HYBRID_APP_EVENTS": "false",
        "FACEBOOK_ANDROID_SDK_VERSION": "5.13.0"
      },
      "cordova-plugin-device": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-x-socialsharing": {},
      "cordova-plugin-file": {},
      "cordova-plugin-googleplus": {
        "REVERSED_CLIENT_ID": "com.googleusercontent.apps.58618556950-lotiu9u12l1jo6nmhkr4j1cqovmj346o",
        "PLAY_SERVICES_VERSION": "15.0.1"
      },
      "cordova-plugin-calendar": {
        "CALENDAR_USAGE_DESCRIPTION": "Add events to your own calendar"
      },
      "cordova-plugin-fcm-with-dependecy-updated": {
        "ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher",
        "ANDROID_FCM_VERSION": "21.0.0",
        "ANDROID_FIREBASE_BOM_VERSION": "26.0.0",
        "ANDROID_GOOGLE_SERVICES_VERSION": "4.3.4",
        "ANDROID_GRADLE_TOOLS_VERSION": "4.1.0"
      },
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-sqlite-storage": {},
      "cordova-plugin-inappbrowser": {}
    },
    "platforms": [
      "android"
    ]
  }
}
EN

回答 1

Stack Overflow用户

发布于 2021-10-01 07:35:17

我解决了这个问题。问题是我全局安装了angular,而"ionic build“试图使用全局ng版本。

删除全局angular版本"ionic build“后,会抱怨缺少@angular/cli。奇怪的是,因为@angular/cli在package.json中列出。

无论如何,在使用建议的npm命令安装它之后,构建会再次运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69375315

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档