【问题标题】:Cannot install Ionic-Native File plugin无法安装 Ionic-Native File 插件
【发布时间】:2018-03-02 08:30:51
【问题描述】:

我有一个 Ionic 3 项目,我正在尝试使用以下命令添加 Ionic Native File 插件:

ionic cordova plugin add cordova-plugin-file

但是,我收到以下错误:

L:\MyTrials\test\ionic\locations-app>ionic cordova plugin add cordova-plugin-file
> cordova plugin add cordova-plugin-file --save
x Running command - failed!
[ERROR] An error occurred while running cordova plugin add cordova-plugin-file

    --save (exit code 1):

    Error: Failed to fetch plugin file:node_modules\cordova-plugin-file via
    registry.
    Probably this is either a connection problem, or plugin spec is
    incorrect.
    Check your connection and plugin name/version/URL.
    Error: cmd: Command failed with exit code 1 Error output:
    npm ERR! code ENOLOCAL
    npm ERR! Could not install from "node_modules\cordova-plugin-file" as it
    does not contain a package.json file.

    npm ERR! A complete log of this run can be found in:
    npm ERR!
    C:\Users\xxx\AppData\Roaming\npm-cache\_logs\2017-09-21T05_16_31_940Z-debug.log

我已经尝试过其他命令,例如:

cordova plugin add cordova-plugin-file

cordova plugin add cordova-plugin-file --nofetch

但我基本上得到了同样的错误。

我的互联网连接很好,我以管理员身份运行了这些命令。

似乎只有文件插件可能有这些问题。我可以毫无问题地安装 Ionic Native Datepicker 插件。

感谢任何帮助!

【问题讨论】:

  • 你能不能先删除插件ionic cordova plugin rm cordova-plugin-file 以及node_modules\cordova-plugin-file 中的文件夹,然后再安装看看会发生什么。
  • @amin arghavani:感谢您的回复!运行命令:ionic cordova plugin rm cordova-plugin-file 给出以下输出:错误:插件“cordova-plugin-file”不存在于项目中。见cordova plugin list。在 node_modules 中,我只找到了一个指向 cordova-plugu-file 的快捷链接,它只是指向 node_modules 文件夹。我现在已经删除了。接下来我尝试使用 ionic 添加cordova-plugin-file - 我再次遇到上述相同的错误。也不知道为什么这个插件没有 package.json 文件...
  • @aminarghavani:除了我之前的评论,我还发现在我的 ionic 项目的 package.json 文件中有对 cordova-plugin-file 的引用。我已删除此条目并尝试通过 ionic 命令添加cordova-plugin-file。这次命令运行成功,没有问题!感谢您在这方面帮助我!

标签: android cordova ionic-framework ionic3 ionic-native


【解决方案1】:

从问题的 cmets 中可以看出,在@amin arghavani 的帮助下,执行以下操作解决了问题:

  1. 如果插件已安装,请删除:ionic cordova plugin rm cordova-plugin-file 在我的情况下,这个插件从未安装过,所以我收到了与错误相同的消息。

  2. 检查项目的node_modules 文件夹下是否存在插件文件夹。 就我而言,我实际上找到了一个以我已删除的插件 (cordova-plugin-file) 命名的快捷方式链接。

  3. 检查插件是否包含在项目的package.json 中作为依赖项或开发人员依赖项。 就我而言,我在 package.json 的依赖项(我删除并保存)下找到了对 cordova-plugin-file 的引用。

  4. 从对我有用的命令行再次添加cordova组件。

【讨论】:

    猜你喜欢
    • 2018-06-03
    • 2019-12-01
    • 2018-02-13
    • 1970-01-01
    • 2017-10-28
    • 2021-12-09
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多