简体   繁体   English

无法从ionic-native - 依赖关系安装'File'?

[英]Unable to install ‘File’ from ionic-native - dependencies related?

So I'm pretty fresh in Ionic2 so I'm getting some newbie troubles =/ I've searched pretty much everything and I can't find any examples for this. 所以我在Ionic2中很新鲜,所以我得到一些新手的麻烦= /我几乎搜索了所有内容,我找不到任何这方面的例子。

What I want to do is to write a file to a certain directory of the device. 我想要做的是将文件写入设备的某个目录。 I'm using Ionic2 and I've seen that there's a ' File API ' that does what I need. 我正在使用Ionic2,我已经看到有一个' File API '可以满足我的需求。 But the problem is that I can't set it up. 但问题是我无法设置它。

Whenever I do $ npm install --save @ionic-native/file I get this output: 每当我执行$ 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.`

But whenever I try to use npm install for these missing dependencies, it keeps giving me the same errors over and over again. 但每当我尝试使用npm install来处理这些缺失的依赖项时,它会一遍又一遍地给我同样的错误。 I'm quite lost here. 我在这里迷路了。 I've tried to delete node_modules, cache clean and install and I still can't get the File to work. 我试图删除node_modules,缓存清理和安装,我仍然无法让文件工作。

If you could assist me here that would be great. 如果你能在这里帮助我,那就太好了。 I can provide other info if needed. 如果需要,我可以提供其他信息。 Cheers! 干杯!

--------- Here are my dependencies from package.json ---------这是我从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": []
}
`

I tried to install it in brand new project and npm also complained about @ionic-native/core missing. 我试图在全新的项目中安装它,npm也抱怨@ ionic-native / core缺失。 In fact, you should try to install it (and other dependencies) separately before installing @ionic-native/file. 实际上,在安装@ ionic-native / file之前,应该尝试单独安装它(以及其他依赖项)。

Hope it helps! 希望能帮助到你!

I've fixed this problem. 我已经解决了这个问题。

1: Remove node_modules, clean cache and install all dependencies again 1:删除node_modules,清理缓存并再次安装所有依赖项

rm -rf node_modules
npm cache clean
npm install

2: In my problem, I needed ionic-native@core to be 3.1.0 or higher to be able to use ionic-native@file. 2:在我的问题中,我需要离子原生@核心为3.1.0或更高才能使用离子原生@文件。 So I run 所以我跑了

npm install --save @ionic-native/core

And it got fixed. 它得到了修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM