"要求"例外科尔多瓦/的PhoneGap项目 [英] "Require" exception in Cordova/phonegap project

查看:183
本文介绍了"要求"例外科尔多瓦/的PhoneGap项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立在Android平台上使用的PhoneGap /科尔多瓦的混合移动应用程序。并根据需要在纹波模拟器在我的Chrome浏览器我已经成功地太:)该应用程序的作品。我不使用Eclipe ADT或Android作为工作室模拟器不加载快。

I am trying to build an hybrid mobile app using Phonegap/Cordova in Android platform. And I have succeeded in that too :) The app works as desired in Ripple emulator in my Chrome browser. I am not using Eclipe ADT or Android Studio as the emulator does not load quick.

我已经使用了震动和警报onDeviceReady事件和浏览器插件。所有这些优秀作品如预期。

I have used onDeviceReady event and Navigator plugin for vibrate and alerts. All these works fine as expected.

在开发者控制台是活跃在Chrome中,JavaScript打破了cordova.js与以下错误

When the Developer Console is active in Chrome, the JavaScript breaks in cordova.js with the following error

Uncaught ReferenceError: require is not defined 

在下面一行。同样的情况对于notification.js文件了。当我preSS调试器继续,一切都从这个错误有望再次分开工作。

in the following line. The same happens for notification.js file too. When I press continue in debugger, everything works again as expected apart from that error.

var cordova_events = require('./src/events'),

在Java脚本文件的顺序分别如下。

Order of the java script files are as given below.

<script src="js/cordova.js"></script>
<script src="js/notification.js"></script>               
<script src="js/vibration.js"></script> 

我相信我不是引用正确的cordova.js文件和其它所有的依赖关系。但我也想知道怎么来不应用程序工作正常时纹波开发者控制台不活跃。

I believe I am not referencing the correct cordova.js file and all other dependencies. But I also wonder how come does the app works fine in Ripple when the developer console is not active.

我甚至试图删除cordova.js文件纹波自动将它包括根据<一个href=\"http://stackoverflow.com/questions/5187089/phonegap-deviceready-event-ripple-emulator\">phonegap deviceready事件 - 波纹模拟器

I even tried to remove cordova.js file as Ripple automatically includes it as per phonegap deviceready event - ripple emulator

我也从他们各自的网站的PhoneGap和科尔多瓦的下载副本。我已经安装了Node.js的,并已安装的软件包了。

I have the download copies of phonegap and cordova from their respective sites. I have installed Node.js and have installed the packages too.

我这里的问题是:


  • 在哪里可以找到正确的cordova.js文件?这是包含在我的HTML文件的项目版本是否正确?

  • 什么是Node.js的用户在这里?

  • 它是否旨在自动包括基于Node.js的脚本?如果是这样,我缺少的是什么?

我承认,Node.js的概念和使用看起来像火箭科学对我来说。

I confess that the concept and usage of node.js looks like a rocket science for me.

推荐答案

科尔多瓦与PhoneGap的是pretty同样的事情,你不应该需要下载两个。科尔多瓦是开源项目,帮助您发布HTML5应用多种不同的移动操作系统。 PhoneGap的使用科尔多瓦要做到这一点,还增加了一些额外的功能,大多只是能够建立在云中,而不是在工作站上。

Cordova and Phonegap are pretty much the same thing, you shouldn't need to download both. Cordova is the open source project that helps you publish your HTML5 app to multiple different mobile OSes. Phonegap uses Cordova to do that, but also adds some extra features, mostly just being able to build in the cloud instead of on your workstation.

Node.js的为很多建设步骤,使用的科尔多瓦。由于科尔多瓦适用于OSX和Windows机器上,我们需要一种方式来写编译和打包脚本,将在两个操作系统上运行 - Node.js的提供这一点。当你与科尔多瓦构建一个应用程序,你应该没有真正使用Node.js的所有,除非你也建立一个互补的后端系统。

Node.js is used by Cordova for a lot of the building steps. Since Cordova works on OSX and Windows machines, we needed a way to write build and package scripts that would work on both operating systems - node.js provides this. When you build an application with Cordova you shouldn't really use node.js at all, unless you are also building a complementary backend system.

与科尔多瓦3.x的开始,有一个科尔多瓦命令行工具,可以极大地帮助您创建应用程序。它需要复制权cordova.js和科尔多瓦-的android.jar文件的照顾。你可以在这里读到它的http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface

Starting with Cordova 3.x, there is a cordova command line tool that can greatly help you create the application. It takes care of copying the right cordova.js and cordova-android.jar files. You can read about it here http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface

一旦你设置你可能想读我的报告澄清了一些科尔多瓦工具的使用情况下,对方的回答:<一href=\"http://stackoverflow.com/questions/19112436/should-a-phonegap-plugin-be-declared-in-the-config-xml-file/19125861#19125861\">Should一个PhoneGap的插件在config.xml文件中声明?

Once you get set up you might want to read my other answer that clarifies some of the use cases of cordova tool: Should a phonegap plugin be declared in the config.xml file?

这篇关于&QUOT;要求&QUOT;例外科尔多瓦/的PhoneGap项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆