科尔多瓦运行ubuntu不起作用

时间:2014-04-20 03:56:36

标签: node.js ubuntu cordova

我安装了Ubuntu 14.04并且无法使用" cordova运行ubuntu"来运行应用程序,出现以下错误:

paulo@paulo-notebook:~/hello$ sudo cordova run ubuntu
ReferenceError: name is not defined
    at Object.ConfigParser.setDescription (/usr/local/lib/node_modules/cordova/src/ConfigParser.js:70:45)
    at Object.module.exports.update_from_config (/usr/local/lib/node_modules/cordova/src/metadata/ubuntu_parser.js:74:21)
    at Object.module.exports.update_project (/usr/local/lib/node_modules/cordova/src/metadata/ubuntu_parser.js:156:21)
    at /usr/local/lib/node_modules/cordova/src/prepare.js:113:31
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:821:14
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

早些时候在执行" cordova平台添加ubuntu"

时也会出现以下错误
paulo@paulo-notebook:~/hello$ cordova platform add ubuntu
Downloading cordova library for ubuntu...
Download complete
Checking ubuntu requirements...
Running "dpkg-query -Wf'${db:Status-abbrev}' cmake debhelper libx11-dev libicu-dev pkg-config qtbase5-dev qtchooser qtdeclarative5-dev qtfeedback5-dev qtlocation5-dev qtmultimedia5-dev qtpim5-dev qtsensors5-dev qtsystems5-dev 2>/dev/null | grep -q '^i'" (output to follow)

Creating ubuntu project...
Shelljs module was not found, running 'npm install'.....
ReferenceError: name is not defined
    at Object.ConfigParser.setDescription (/usr/local/lib/node_modules/cordova/src/ConfigParser.js:70:45)
    at Object.module.exports.update_from_config (/usr/local/lib/node_modules/cordova/src/metadata/ubuntu_parser.js:74:21)
    at Object.module.exports.update_project (/usr/local/lib/node_modules/cordova/src/metadata/ubuntu_parser.js:156:21)
    at /usr/local/lib/node_modules/cordova/src/prepare.js:113:31
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:760:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:821:14
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

有谁知道会是什么?

2 个答案:

答案 0 :(得分:2)

这是Cordova的JavaScript错误,您可以按照以下步骤进行修复

$ sudo vim /usr/local/lib/node_modules/cordova/src/ConfigParser.js

转到第69行。在这里您可以找到:

setDescription: function() {
    this.doc.find('description').text = name;
    var el = findOrCreate(this.doc, 'description');
},

问题出在第70行,由名为name的变量引起:它未定义。 要修复此错误,您需要添加name作为setDescription函数的输入参数,如下所示:

setDescription: function(name) {
    this.doc.find('description').text = name;
    var el = findOrCreate(this.doc, 'description');
},

保存更改。由于添加了Ubuntu平台 - 我假设不正确 - 你应该进入你的Cordova项目的平台目录并删除ubuntu目录

$ cd ~/hello/platforms
$ rm -r ubuntu

现在你需要重新运行:

$ cordova platform add ubuntu

最后它应该没有错误地运行。

我已经向Apache Software Fundation提出了一个问题:https://issues.apache.org/jira/browse/CB-6643

答案 1 :(得分:1)

正确的语法是cordova run "supported platforms" /cordova add "supported platforms"。并且 ubunto 不是受支持的平台。

查看此页面:Apache Cordova Documentation - The Command-line Interface

支持的平台是:

  • iOS
  • Android
  • 黑莓
  • Windows Phone 8

例如:cordova添加android / cordova运行wp8,....