无法安装 Cordova 插件条形码 Phonegap (mac)

Unable to install Cordova plugin barcode Phonegap (mac)

我是 cordova 和 phonegap 的新手。我需要安装 Cordova 插件 barcodescanner,我尝试通过终端 (mac) 使用以下行来安装:

cordova plugin add cordova-plugin-barcodescanner 在此 document.

但是,我收到无法解决的错误。我已经阅读了很多其他帖子,但还没有找到适合我的情况的解决方案。

我的错误:

(node:1721) UnhandledPromiseRejectionWarning: CordovaError: Cannot 
find plugin.xml for plugin "cordova-plugin-barcodescanner". Please 
try adding it again.
at new PluginInfo 
(/usr/local/lib/node_modules/cordova/node_modules/cordova- 
common/src/PluginInfo/PluginInfo.js:367:15)
at PluginInfoProvider.get 
(/usr/local/lib/node_modules/cordova/node_modules/cordova- 
common/src/PluginInfo/PluginInfoProvider.js:35:32)
at /usr/local/lib/node_modules/cordova/node_modules/cordova- 
lib/src/plugman/fetch.js:177:51
at _fulfilled 
(/usr/local/lib/node_modules/cordova/node_modules/cordova- 
lib/node_modules/q/q.js:787:54)
at self.promiseDispatch.done 
(/usr/local/lib/node_modules/cordova/node_modules/cordova- 
lib/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch 
(/usr/local/lib/node_modules/cordova/node_modules/cordova- 
lib/node_modules/q/q.js:749:13)
at /usr/local/lib/node_modules/cordova/node_modules/cordova- 
lib/node_modules/q/q.js:509:49
at flush (/usr/local/lib/node_modules/cordova/node_modules/cordova- 
lib/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)
 (node:1721) UnhandledPromiseRejectionWarning: Unhandled promise 
 rejection. This error originated either by throwing inside of an 
 async function without a catch block, or by rejecting a promise 
 which 
 was not handled with .catch(). (rejection id: 1)
 (node:1721) [DEP0018] DeprecationWarning: Unhandled promise 
 rejections 
 are deprecated. In the future, promise rejections that are not 
 handled 
 will terminate the Node.js process with a non-zero exit code.

这些是我的规格: iOS:10.13.4 电话差距:0.4.5

谢谢! :)

  1. https://github.com/hypery2k/cordova-barcodescanner-plugin 尝试使用完整的 url 安装插件。

2.Set <plugin name="cordova-plugin-barcodescanner" spec="0.7.4" /> 到 config.xml 然后用你的命令尝试 运行 cordova plugin add cordova-plugin-barcodescanner

如果它不起作用尝试 运行 命令 npm install cordova-plugin-barcodescanner。 (如果您的命令已经将一些文件添加到插件文件夹,请将其删除并再次运行。)

检查您尝试安装插件的路径,它必须类似于 C:/Desktop/Application/www/plugin/

请确保您的 config.xml 有:

<config-file target="AndroidManifest.xml" parent="/*" mode="merge">
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>

好的,经过多天的试验,我明白了。 基本上我所做的是使用 CLI 从头开始​​创建一个新项目。然后我一步步跟着this documentation。当我到达 "plugin" 部分时,我使用以下行添加了我想要的插件:

cordova plugin add cordova-plugin-barcodescanner

希望这对其他人有帮助。 干杯!