node.js - 无法从 ionic-native 安装 ‘File’ - 依赖项相关?

标签 node.js cordova angular ionic2 cordova-plugins

所以我对 Ionic2 还很陌生,所以我遇到了一些新手麻烦=/我已经搜索了几乎所有内容,但找不到任何示例。

我想做的是将文件写入设备的某个目录。我正在使用 Ionic2,我看到有一个 ' File API ' 这就是我所需要的。但问题是我无法设置它。

每当我执行 $ npm install --save @ionic-native/file 时,我都会得到以下输出:

`project@0.0.1 D:\project\
+-- UNMET PEER DEPENDENCY @angular/core@2.2.1
+-- UNMET PEER DEPENDENCY @ionic-native/core@^3.1.0
+-- @ionic-native/file@3.2.1
-- UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12`

`npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @ionic-native/file@3.2.1 requires a peer of @ionic-native/core@^3.1.0 but none was installed.
npm WARN @ionic-native/file@3.2.1 requires a peer of @angular/core@2.4.8 but none was installed.
npm WARN @ionic-native/file@3.2.1 requires a peer of rxjs@5.0.1 but none was installed.`

但是每当我尝试使用 npm install 来安装这些缺失的依赖项时,它都会一遍又一遍地给我同样的错误。我在这里很迷路。我尝试删除node_modules、清理缓存并安装,但仍然无法使该文件正常工作。

如果您能在这里帮助我,那就太好了。如果需要的话我可以提供其他信息。干杯!

--------- 这是我来自 package.json

的依赖项
`
{
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic-native/file": "^3.2.1",
    "@ionic/storage": "1.1.7",
    "@ngx-translate/core": "^6.0.0",
    "@ngx-translate/http-loader": "0.0.3",
    "cordova": "^6.5.0",
    "ionic-angular": "2.0.1",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "jquery": "^3.1.1",
    "rxjs": "5.0.0-beta.12",
    "sw-toolbox": "3.4.0",
    "xml2json": "^0.11.0",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.1.0",
    "@types/jquery": "^2.0.41",
    "jscs": "^3.0.7",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-statusbar",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": []
}
`

最佳答案

我已经解决了这个问题。

1:删除node_modules,清理缓存并再次安装所有依赖项

rm -rf node_modules
npm cache clean
npm install

2:在我的问题中,我需要 ionic-native@core 为 3.1.0 或更高版本才能使用 ionic-native@file。所以我跑了

npm install --save @ionic-native/core

它已经修复了。

关于node.js - 无法从 ionic-native 安装 ‘File’ - 依赖项相关?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42981426/

相关文章:

Android 4.1 视口(viewport)缩放(setInitialScale,meta initial-scale 不工作)

html - 样式化 Angular 组件

node.js - 如何使用 Bower 组件文件的正确路径设置 Node 项目

javascript - 撇号 CMS - afterInsert 被多次调用

android - Cordova 恢复事件未在一台设备中触发

javascript - Android 4.3 上使用 Phonegap 中的 FileTransfer 将文件上传到 S3 时的代码 3

angular - react 形式的 formGroup.get 与 formGroup.controls - Angular

Angular 12 更新问题 : Unknown error from PostCSS plugin

node.js - 异步功能不起作用

javascript - 在 Express.js 应用程序的公共(public)文件夹中创建一个文件