【问题标题】:Cannot find module 'UNMET/package.json'找不到模块“UNMET/package.json”
【发布时间】:2019-10-18 03:01:05
【问题描述】:

我正在尝试在我的 ionic 应用程序中安装一个 cordova 插件。但是每次我尝试安装的每个插件都会抛出一个错误:

找不到模块“UNMET/package.json”

我已经多次删除路径:node_modules、插件、平台、www。

我跑:

npm 安装

ionic cordova 插件添加 cordova-plugin-local-notification

ionic cordova 平台添加android

我试着改变这个顺序,但问题没有解决。

我在 Ubuntu 18 中运行,ionic 版本是 4.8.0,cordova 版本是 9.0.0,cordova-lib 9.0.1,node 版本 8.10.0,npm 3.5.2。

我只是在终端中运行这一行:

ionic cordova plugin add cordova-plugin-local-notification

我的包 json:

{
  "name": "project-name",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "android": "ionic cordova run android",
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "buildAndroid": "ionic cordova build android --aot --minifyjs --minifycss"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/fire": "^5.1.1",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/background-geolocation": "^4.20.0",
    "@ionic-native/base64": "^4.20.0",
    "@ionic-native/camera": "^4.20.0",
    "@ionic-native/core": "~4.18.0",
    "@ionic-native/crop": "^4.20.0",
    "@ionic-native/facebook": "^4.20.0",
    "@ionic-native/geolocation": "^4.20.0",
    "@ionic-native/google-plus": "^4.20.0",
    "@ionic-native/local-notifications": "^4.20.0",
    "@ionic-native/location-accuracy": "^4.20.0",
    "@ionic-native/social-sharing": "^4.20.0",
    "@ionic-native/splash-screen": "~4.18.0",
    "@ionic-native/sqlite": "^4.20.0",
    "@ionic-native/status-bar": "~4.18.0",
    "@ionic/storage": "2.2.0",
    "@mauron85/cordova-plugin-background-geolocation": "3.0.3",
    "brmasker-ionic-3": "^1.6.3",
    "com-badrit-base64": "^0.2.0",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-crop": "^0.4.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-geolocation": "4.0.2",
    "cordova-plugin-googleplus": "7.0.2",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^3.1.2",
    "cordova-plugin-local-notification": "0.9.0-beta.2",
    "cordova-plugin-request-location-accuracy": "2.3.0",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-socialsharing": "5.4.7",
    "cordova-sqlite-storage": "^3.2.0",
    "es6-promise-plugin": "4.2.2",
    "firebase": "^5.8.4",
    "ionic-angular": "3.9.3",
    "ionicons": "3.0.0",
    "ngx-multilingual": "0.0.3",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.29"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.1",
    "@ionic/lab": "1.0.20",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova-sqlite-storage": {},
      "com-badrit-base64": {},
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-crop": {},
      "cordova-plugin-mauron85-background-geolocation": {
        "GOOGLE_PLAY_SERVICES_VERSION": "11+",
        "ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
        "ICON": "@mipmap/icon",
        "SMALL_ICON": "@mipmap/icon",
        "ACCOUNT_NAME": "@string/app_name",
        "ACCOUNT_LABEL": "@string/app_name",
        "ACCOUNT_TYPE": "$PACKAGE_NAME.account",
        "CONTENT_AUTHORITY": "$PACKAGE_NAME"
      },
      "cordova-plugin-googleplus": {
        "PLAY_SERVICES_VERSION": "11.8.0"
      },
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "Para pegar as melhores promoções"
      },
      "cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
      },
      "cordova-plugin-local-notification": {}
    },
    "platforms": [
      "android"
    ]
  }
}

但是每个插件都会抛出这个错误。

我只需要再次在我的应用中安装插件。

【问题讨论】:

  • 能不能发一下json包
  • 确保你在项目根目录中
  • 我编辑了问题,添加了 package.json @ORBIT

标签: ionic-framework ionic3 cordova-plugins


【解决方案1】:

只需更新 npm,您就可以再次构建 :)

【讨论】:

  • 欢迎来到社区,感谢您留下答案。如果 OP 不熟悉包管理和包存储库,您能否提供更多细节?关于使用包管理器的工作流程的几句话会很棒。也许还有关于从哪里获得更多信息的声明。我会这样做,但 npm 不是我的强项。无论如何,这是你的答案,你应该得到所有的功劳!谢谢!
猜你喜欢
  • 2021-12-21
  • 2020-10-09
  • 2017-01-09
  • 1970-01-01
  • 2023-01-23
  • 2020-01-21
  • 1970-01-01
  • 1970-01-01
  • 2020-12-09
相关资源
最近更新 更多