【发布时间】: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