我正按照以下说明在Ubuntu 13.10上安装Apache Cordova: http://cordova.apache.org/docs/en/3.5.0//guide_cli_index.md.html#The%20Command-Line%20Interface
我被困在了#34;添加平台":
部分$ cordova platforms ls
Installed platforms:
Available platforms: amazon-fireos, android, blackberry10, firefoxos, ubuntu
看起来像Ubuntu可用。所以我继续。
$ cordova platform add ubuntu
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)
Make sure you have the following packages installed:
user@host:/opt/lampp/htdocs/hello$
看起来很奇怪,因为它警告我在给定空列表的情况下安装包。
$ cordova build
No platforms added to this project. Please use `cordova platform add <platform>`.
......它没有用。
$ cordova platforms ls
Installed platforms:
Available platforms: amazon-fireos, android, blackberry10, firefoxos, ubuntu
看起来像以前一样。
有什么想法吗?
补充:
与
$ cordova -d platform add ubuntu
我得到以下内容:
CordovaError: Make sure you have the following packages installed:
at /usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/metadata/ubuntu_parser.js:56:22
at /usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/shell.js:1727:7
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Socket.<anonymous> (child_process.js:968:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
补充2:
好的,我通过sudo apt-get install ......添加了所有缺少的库......
现在我明白了:
$ cordova -d platform add ubuntu
cordova library for "ubuntu" already exists. No need to download. Continuing.
Checking if platform "ubuntu" passes minimum requirements...
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...
Running command: /home/user/.cordova/lib/ubuntu/cordova/3.5.0/bin/create /opt/lampp/htdocs/hello/platforms/ubuntu com.example.hello HelloWorld
Shelljs module was not found, running 'npm install'.....
ERROR : running 'npm install' is npm installed? Error: Command failed: npm WARN package.json cordova-ubuntu@0.0.0 No README data
npm ERR! Error: Attempt to unlock shelljs@0.2.6, which hasn't been locked
npm ERR! at unlock (/usr/lib/node_modules/npm/lib/utils/locker.js:44:11)
npm ERR! at cb (/usr/lib/node_modules/npm/lib/cache/add-named.js:32:5)
npm ERR! at /usr/lib/node_modules/npm/lib/cache/add-named.js:41:20
npm ERR! at /usr/lib/node_modules/npm/lib/utils/locker.js:30:7
npm ERR! at /usr/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
npm ERR! at OpenReq.Req.done (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
npm ERR! at OpenReq.done (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.11.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/user/.cordova/lib/ubuntu/cordova/3.5.0/bin
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! Error: Attempt to unlock elementtree@*, which hasn't been locked
npm ERR! at unlock (/usr/lib/node_modules/npm/lib/utils/locker.js:44:11)
npm ERR! at cb (/usr/lib/node_modules/npm/lib/cache/add-named.js:32:5)
npm ERR! at /usr/lib/node_modules/npm/lib/cache/add-named.js:41:20
npm ERR! at /usr/lib/node_modules/npm/lib/utils/locker.js:30:7
npm ERR! at /usr/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
npm ERR! at OpenReq.Req.done (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
npm ERR! at OpenReq.done (/usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
....[several other lines with similar errors].....
Command finished with error code 1: /home/user/.cordova/lib/ubuntu/cordova/3.5.0/bin/create /opt/lampp/htdocs/hello/platforms/ubuntu,com.example.hello,HelloWorld
Error: /home/user/.cordova/lib/ubuntu/cordova/3.5.0/bin/create: Command failed with exit code 1
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)
是的,npm已安装
通过更改&#34; root&#34;中的/home/user/.npm的所有权来解决到&#34;用户&#34;
但是,下一个问题仍然存在:
$ cordova build
Running command: /opt/lampp/htdocs/hello/platforms/ubuntu/cordova/build
/opt/lampp/htdocs/hello/platforms/ubuntu/cordova/check_reqs
Error: missing dependency cmake libicu-dev pkg-config qtbase5-dev qtchooser qtdeclarative5-dev qtfeedback5-dev qtlocation5-dev qtmultimedia5-dev qtpim5-dev qtsensors5-dev qtsystems5-dev
/opt/lampp/htdocs/hello/platforms/ubuntu/cordova/check_reqs FAILED
Error: /opt/lampp/htdocs/hello/platforms/ubuntu/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)
我已经安装了这些:cmake libicu-dev pkg-config qtbase5-dev qtchooser qtdeclarative5-dev qtfeedback5-dev qtlocation5-dev qtmultimedia5-dev qtpim5-dev qtsensors5-dev qtsystems5-dev
答案 0 :(得分:1)
错误消息看起来已损坏,但这是您需要的deps:
cmake libicu-dev pkg-config qtbase5-dev qtchooser qtdeclarative5-dev qtfeedback5-dev qtlocation5-dev qtmultimedia5-dev qtpim5-dev qtsensors5-dev qtsystems5-dev
至少根据这个github链接:link
您可能希望在执行添加平台代码时添加-d
以获取额外的调试信息,例如cordova -d platform add ubuntu
编辑:
经过以下提问:
您可以致电apt-get install <insert package list>
来安装软件包。
EDIT2:
评论后再次提供更多信息。不确定为什么它会失败,因为你似乎确实安装了npm吗?
您可以从调用create命令的位置执行以下操作,不正确的位置,但可能会使其正常工作
npm install shelljs@0.2.6 elementtree colors@0.6.2 optimist@0.6.0 q@2.0。*
答案 1 :(得分:1)
根据Cordova开发人员的说法,此问题已在最新版本中修复:
https://github.com/apache/cordova-lib/commit/153092f2c235185c7f141979a550779800954a92
尝试替换运行
npm -g explore cordova
并用GitHub中最新版本的cordova-lib替换node_modules/cordova-lib
的内容。
答案 2 :(得分:0)
当你打开platform / ubuntu / cordova / check_reps的代码时,你会发现一些有趣的东西:
var deps = "cmake libicu-dev pkg-config qtbase5-dev qtchooser qtdeclarative5-dev qtfeedback5-dev qtlocation5-dev qtmultimedia5-dev qtpim5-dev qtsensors5-dev qtsystems5-dev";
exec("dpkg-query -Wf'${db:Status-abbrev}\\n' click " + deps, function(error, stdout, stderr)
这将调用以下shell命令:
dpkg-query -Wf'${db:Status-abbrev}\n' click cmake libicu-dev [and so on...]
我不知道为什么“click”包不包含在deps字符串中,但它也是必需的,并且错误消息不会告诉你。
我发现安装点击可以解决问题:
sudo apt-get install click
祝你好运!
BTW我在这里发布了一个相同的答案:Build Command in Apache Cordova