[英]Can't add downloaded plugin to Cordova/Phonegap project
How can I get a plugin to work by installing it NOT from the repository. 我如何通过不在存储库中安装插件来使其正常工作。 Each plugin I try to install using
phonegap plugin add <<git repository>>
always results in different errors, because windows + npm just doesn't want to work for me... 我尝试使用
phonegap plugin add <<git repository>>
来安装的每个插件始终会导致不同的错误,因为Windows + npm只是不想为我工作...
This is the plugin I need: https://github.com/VersoSolutions/CordovaClipboard 这是我需要的插件: https : //github.com/VersoSolutions/CordovaClipboard
My steps: 我的步骤:
phonegap plugin add <<downloaded and extracted directory>>
phonegap plugin add <<downloaded and extracted directory>>
But cordova.plugins.clipboard
is still undefined. 但是
cordova.plugins.clipboard
仍未定义。 Do I have to put the clipboard.js file somewhere or reference it? 我是否必须将剪贴板.js文件放在某个地方或引用它? If so, which version?
如果是这样,哪个版本? The one in the clipboard project or the one phonegap automatically creates within the platform/android directory (it puts a "define" around it).
剪贴板项目中的一个或一个phonegap会在platform / android目录中自动创建(在它的周围放置一个“定义”)。 I actually tried both, but the object was still undefined.
实际上,我都尝试过,但是对象仍然不确定。
The clipboard plugin does not have a package.json
present which is why you are getting the error. 剪贴板插件没有
package.json
出现,这就是您收到错误的原因。 You can either add a package.json
file to the plugin or you can install it with the --nofetch
flag: 您可以将
package.json
文件添加到插件,也可以使用--nofetch
标志进行安装:
cordova/phonegap plugin add https://github.com/VersoSolutions/CordovaClipboard.git --nofetch
Since cordova 7.0.0 npm install
is run by default when adding a new plugin which causes an error if no package.json
is present. 由于cordova 7.0.0
npm install
会在添加新插件时默认运行,如果不存在package.json
,则会导致错误。 You can find the release notes for cordova 7.0.0 here . 您可以在此处找到cordova 7.0.0的发行说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.