升级Cordova:无法再安装来自Git URL的插件。

24

我进行了cordova/phonegap升级,现在无法再从git url安装插件。有人遇到过这样的问题并已经解决了吗?

$ cordova plugin add https://github.com/dawsonloudon/VideoPlayer.git
Fetching plugin "https://github.com/dawsonloudon/VideoPlayer.git" via git clone
Repository "https://github.com/dawsonloudon/VideoPlayer.git" checked out to git ref "master".
shell.js: internal error
Error: EXDEV, cross-device link not permitted '/var/folders/xl/bkl76rm570gfsmjspfjgh45h0000gn/T/git/1434106220728/LICENSE'
    at Object.fs.renameSync (fs.js:554:18)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/mv.js:77:8
    at Array.forEach (native)
    at Object._mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/mv.js:53:11)
    at Object.mv (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/common.js:186:23)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/plugins.js:53:19
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:557:44

版本信息:

$ phonegap -v
5.0.0-0.28.1

$ cordova -v
5.1.1

OSX 10.10.3

编辑: 如果我将我的存储库移动到我的主目录(〜/),似乎它可以工作。


Git 和 Node 呢? - Vishal Singh
似乎无法拉取VideoPlayer插件。 - Vishal Singh
你尝试过使用其他随机的 Cordova 插件来测试一下是插件的问题还是你的 Cordova 设置有误吗? - Guillaume Munsch
1
对我来说问题在于我的项目在/home中,与/tmp不同的分区,而这是cordova正在克隆存储库的地方。我不知道为什么这对shell.js是个问题。 - tonicebrian
@mwager,您可以在下面选择答案作为正确答案。每个人都遇到过这个问题,但克隆会修复它。 - Pian0_M4n
显示剩余2条评论
10个回答

26

我在Windows 7上使用Cordova时遇到了同样的问题。我不得不回滚到5.0.0版本(npm install -g cordova@5.0.0)才能让它再次正常工作。


1
这个对我解决了问题,我已经提交了一个Cordova bug报告:https://issues.apache.org/jira/browse/CB-9212。 - Michael

26

一个快速解决方法是将git克隆到本地并从那里提供路径。为了让插件开始工作,它只需要看到plugin.xml文件。

因此,cordova plugin add https://github.com/phonegap/phonegap-plugin-fast-canvas.git --失败,因为

shell.js: internal error Error: EXDEV,不允许跨设备链接 '/--Cordova 5.1.0+中的常规错误。适用于大多数(如果不是所有).git安装程序

本地克隆 :: git clone https://github.com/phonegap/phonegap-plugin-fast-canvas.git

本地安装 cordova plugin add /path/to/phonegap-plugin-fast-canvas

可以正常工作。


请检查您的语法,git clone cordova plugin add https://github.com/phonegap/phonegap-plugin-fast-canvas.git 是不正确的。 - Anne van Rossum
1
感谢 @AnnevanRossum。已修复。 - Pian0_M4n

5

此问题已在最新的cordova版本(5.2.0)中得到解决。

使用npm install -g cordova来升级Cordova。


4

为了补充其他优秀回答的内容,

作为临时解决方法,这里提供一个一行代码的方法,可以将Cordova降级、安装插件并升级Cordova:

npm install -g cordova@5.0.0 && cordova plugin add [plugin url] && npm install -g cordova

需要一些时间来执行,但可以消除所有手动克隆存储库的工作。


迄今为止最简单的方法是这样做。 - Richard Le Mesurier

2

我曾经遇到了和你相同的情况。解决这个问题需要将 Cordova 版本回退到 5.0.0。


2

问题出在node.js fs.rename()上,它无法跨设备重命名文件。

一个可能的解决方法是在cordova/node_modules/cordova-lib/node_modules/shelljs/src/mv.js中用其他方法替换fs.renameSync()

例如:

var run=require('sync-runner');
...
run("mv '"+src+"' '"+thisDest+"'");

1

1

如果你在使用 Cordova 7.0.1 或更新版本时遇到同样的问题,可以通过在项目基目录中包含 package.json 文件并确保该文件中的版本符合 X.X.X 的形式(例如 1.0.0),否则会出现无效版本错误。


1

我也遇到了同样的问题,按照AMilassin的建议(回滚到Cordova Version 5.0),问题得以解决。另一个问题是我的Git安装路径(C:\Program Files\Git\bin)没有被添加到环境变量中。解决这两个问题后,我成功地安装了所需的插件。


1
Cordova 5.1.1存在一个bug,可能会导致从Git repo安装的插件在项目位于不同驱动器的临时文件夹上失败,并显示错误“Error: EXDEV, cross-device link not permitted”。您可以从npm添加插件。或者,如果必须添加插件的Git版本,则可以下载副本,解压缩它,并通过将其放入config.xml并在“spec”中指定目录路径来从文件系统中添加插件:https://cordova.apache.org/docs/en/latest/config_ref/index.html#plugin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接