我有一个启用了两个平台的cordova应用程序,ios和android。我试图使用geolocation插件,但在构建期间我收到一条错误消息。运行“cordova build ios”或“cordova build android”会在构建开始时生成以下输出:
Discovered plugin "Geolocation" in config.xml. Adding it to the project
Failed to restore plugin "Geolocation" from config.xml. You might need to try adding it again. Error: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/Geolocation
npm ERR! 404
npm ERR! 404 'Geolocation' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because
npm ERR! 404 1. name can no longer contain capital letters
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ahnilica/.npm/_logs/2018-01-29T22_15_59_955Z-debug.log
.
.
.
.
构建成功,但地理定位服务在应用程序中不起作用。我尝试删除并重新添加插件,但结果是一样的。
Global Config.xml:
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
<engine name="android" spec="^6.3.0" />
<engine name="ios" spec="^4.5.3" />
Android Config.xml:
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
<param name="onload" value="true" />
</feature>
<feature name="Whitelist">
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
<param name="onload" value="true" />
</feature>
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.Geolocation" />
</feature>
iOS Config.xml:
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<feature name="Console">
<param name="ios-package" value="CDVLogger" />
<param name="onload" value="true" />
</feature>
<feature name="HandleOpenUrl">
<param name="ios-package" value="CDVHandleOpenURL" />
<param name="onload" value="true" />
</feature>
<feature name="IntentAndNavigationFilter">
<param name="ios-package" value="CDVIntentAndNavigationFilter" />
<param name="onload" value="true" />
</feature>
<feature name="GestureHandler">
<param name="ios-package" value="CDVGestureHandler" />
<param name="onload" value="true" />
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen" />
<param name="onload" value="true" />
</feature>
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
Cordova版本:8.0.0 NPM版本:5.6.0