Cordova插件恢复失败

时间:2018-02-22 13:59:25

标签: cordova ionic-framework ionic2 ionic3 cordova-plugins

最近,我的应用程序的Cordova插件的恢复已经开始失败,尽管我没有改变。我在config.xmlpackage.json中绝对指定我的版本,没有插入符号或其他修饰符,以允许安装除指定版本之外的其他版本。我不知道是什么导致这突然中断,我不明白发生的错误。以下是一个相关错误示例的片段,从config.xml指定的插件开始,它可以解决问题:

Discovered plugin "cordova-plugin-code-push" in config.xml. Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "cordova-plugin-code-push@1.10.1"
Running command: npm install cordova-plugin-code-push@1.10.1 --production --no-save
Command finished with error code 0: npm install,cordova-plugin-code-push@1.10.1,--production,--no-save
Copying plugin "/Users/distiller/BallStreetApp/node_modules/cordova-plugin-code-push" => "/Users/distiller/BallStreetApp/plugins/cordova-plugin-code-push"
Calling plugman.install on plugin "/Users/distiller/BallStreetApp/plugins/cordova-plugin-code-push" for platform "ios
Installing "cordova-plugin-code-push" for ios
Running command: /Users/distiller/BallStreetApp/platforms/ios/cordova/version 
Command finished with error code 0: /Users/distiller/BallStreetApp/platforms/ios/cordova/version 
Dependencies detected, iterating through them...
Requesting plugin "code-push@2.0.4".
Plugin dependency "code-push" not fetched, retrieving then installing.
Running command: npm install code-push@2.0.4 --production --no-save
Command finished with error code 0: npm install,code-push@2.0.4,--production,--no-save
Copying plugin "/Users/distiller/BallStreetApp/node_modules/code-push" => "/Users/distiller/BallStreetApp/plugins/code-push"
Installing "code-push" for ios
Finding scripts for "before_plugin_install" hook from plugin code-push on ios platform only.
No scripts found for hook "before_plugin_install".
Install start for "code-push" on ios.
Beginning processing of action stack for ios project...
Action stack processing complete.
Install complete for code-push on ios.
Finding scripts for "after_plugin_install" hook from plugin code-push on ios platform only.
No scripts found for hook "after_plugin_install".
Requesting plugin "cordova-plugin-file@>=4.3.0".
Plugin dependency "cordova-plugin-file" not fetched, retrieving then installing.
Running command: npm install cordova-plugin-file@>=4.3.0 --production --no-save
Command finished with error code 0: npm install,cordova-plugin-file@>=4.3.0,--production,--no-save
Copying plugin "/Users/distiller/BallStreetApp/node_modules/cordova-plugin-file" => "/Users/distiller/BallStreetApp/plugins/cordova-plugin-file"
Installing "cordova-plugin-file" for ios
Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-file on ios platform only.
No scripts found for hook "before_plugin_install".
Install start for "cordova-plugin-file" on ios.
Beginning processing of action stack for ios project...
Action stack processing complete.
Install complete for cordova-plugin-file on ios.
Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-file on ios platform only.
No scripts found for hook "after_plugin_install".
Requesting plugin "cordova-plugin-file-transfer@>=1.3.0".
Plugin dependency "cordova-plugin-file-transfer" not fetched, retrieving then installing.
Running command: npm install cordova-plugin-file-transfer@>=1.3.0 --production --no-save
Command finished with error code 0: npm install,cordova-plugin-file-transfer@>=1.3.0,--production,--no-save
Copying plugin "/Users/distiller/BallStreetApp/node_modules/cordova-plugin-file" => "/Users/distiller/BallStreetApp/plugins/cordova-plugin-file"
Failed to install 'cordova-plugin-code-push': Error: Expected plugin to have ID "cordova-plugin-file-transfer" but got "cordova-plugin-file".
    at checkID (/Users/distiller/BallStreetApp/node_modules/cordova-lib/src/plugman/fetch.js:215:15)
    at /Users/distiller/BallStreetApp/node_modules/cordova-lib/src/plugman/fetch.js:199:9
    at _fulfilled (/Users/distiller/BallStreetApp/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/distiller/BallStreetApp/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/distiller/BallStreetApp/node_modules/q/q.js:749:13)
    at /Users/distiller/BallStreetApp/node_modules/q/q.js:557:44
    at flush (/Users/distiller/BallStreetApp/node_modules/q/q.js:108:17)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to restore plugin "cordova-plugin-code-push" from config.xml. You might need to try adding it again. Error: Error: Expected plugin to have ID "cordova-plugin-file-transfer" but got "cordova-plugin-file".

我不确定它是如何混淆的,当它明显试图安装另一个包时开始尝试寻找一个包。

这是在Cordova 7.1上,但我也尝试过简要升级到Cordova 8,看它是否解决了这个问题。 (它没有。)

我为Ionic标记了问题。我没有使用Ionic,但是因为如果我通过Ionic工具集进行恢复,可能会发生相同的错误,因为它是Cordova的薄包装。

1 个答案:

答案 0 :(得分:0)

这似乎已在cordova-plugin-code-push的v1.11.11中得到修复(参见PR #411)。请注意,如果你有NPM v5.x或更高版本,你可能需要删除或手动更新package-lock.json文件中的cordova-plugin-code-push记录。