在Cordova项目中添加自定义本地插件时出错

时间:2017-09-04 16:42:03

标签: cordova plugins visual-studio-2015 visual-studio-cordova

我在VS 2015中创建了一个Cordova应用程序(用于Windows)。此应用程序预计将使用插件来访问托管代码(C#)中实现的功能。我根据预期的架构创建了一个插件。

现在,我在使用

添加插件jn Cordova App时遇到错误
Config -> Plugins-> Custom -> Local ->

Apache Cordova Tools的完整输出是:

------ Ensuring correct global installation of package from source package directory: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\packages\vs-tac
------ Name from source package.json: vs-tac
------ Version from source package.json: 1.0.42
------ Package already installed globally at correct version.
Installing plugin 'D:\Learning\WindowsApp\Window 10\TestPlugin\MTIFirstCalculator'
Starting launch process C:\Users\Manoj\AppData\Roaming\Microsoft\VisualStudio\MDA\vs-npm\2.14.9\node.exe "C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\pluginInstall.js" --action install --projectSourceDir "D:\Learning\WindowsApp\Window 10\FirstCordovaApp\FirstCordovaApp" --pluginName D:\Learning\WindowsApp\Window 10\TestPlugin\MTIFirstCalculator --language en-US  --cliVersion "6.1.1" --npmInstallDir "C:\Users\Manoj\AppData\Roaming\npm"  --loglevel warn  
------ Cordova tools 6.1.1 already installed.
Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.
Executing "before_plugin_add"  hook for all plugins.
No version specified, retrieving version from config.xml
No version given in config.xml, attempting to use plugin engine info
C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\q\q.js:126
                    throw e;
                          ^
Error: Registry returned 404 for GET on https://registry.npmjs.org/FirstCordovaApp
    at makeError (C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12)
    at CachingRegistryClient.<anonymous> (C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14)
    at Request._callback (C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14)
    at Request.self.callback (C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\request\request.js:187:22)
    at Request.emit (events.js:110:17)
    at Request.<anonymous> (C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\request\request.js:1044:10)
    at Request.emit (events.js:107:17)
    at IncomingMessage.<anonymous> (C:\Users\Manoj\AppData\Roaming\npm\node_modules\vs-tac\node_modules\cordova\6.1.1\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\request\request.js:965:12)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
Done

plugin.xml的内容是:

<?xml version="1.0" encoding="UTF-8"?>
<plugin id="MTIFirstCalc" version="0.2.0" xmlns="http://apache.org/cordova/ns/plugins/1.0">
    <name>MTIFirstCalc</name>
    <description>Calculator</description>
    <license>MTI</license>
    <keywords></keywords>
    <repo></repo>
    <issue></issue>

    <js-module src="www/MTIFirstCalc.js" name="MTIFirstCalc">
        <clobbers target="window.MTICalculate" />
    </js-module>

    <!-- windows -->
    <platform name="windows">
        <js-module src="src/windows/MTIFirstCalcProxy.js" name="MTIFirstCalcProxy">
            <merges target="" />
        </js-module>

    </platform>

</plugin>

可能是什么原因?

1 个答案:

答案 0 :(得分:0)

最后我可以解决问题。我不确定它是否是Apache Cordova Tools的错误或限制。

实际问题出在创建插件目录的路径中。在导致插件位置的文件夹名称中不允许space

我的插件保存在D:\Learning\WindowsApp\Window 10\TestPlugin\MTIFirstCalculator文件夹中。

一旦我将路径更改为D:\Learning\WindowsApp\Window10\TestPlugin\MTIFirstCalculator

,我就可以添加插件

请注意,Window10文件夹中的空格已被删除。

即使在Cordova工具6.5.0中也存在错误。