Cordova系列之一开发环境搭建(windows)

来源:互联网 发布:黄金现货数据 编辑:程序博客网 时间:2024/06/06 08:52


操作系统:Windows 7
工作目录:D:\cordova


安装开发环境


步骤1:下载并安装Node.js

到Node.js官网下载安装包(点击打开链接),本文使用的安装包是node-v4.2.3-x86.msi。

如无特殊安装需求,按照提示缺省安装。


步骤2:下载并安装JDK

到oracle官网下载安装包(点击打开链接),本文使用的安装包是jdk-8u65-windows-i586.exe。

如无特殊安装需求,按照提示缺省安装。


步骤3:安装Cordova

打开控制台,输入 npm install -g cordova

安装日志

C:\Users\user>npm install -g cordovaC:\Users\user\AppData\Roaming\npm\cordova -> C:\Users\user\AppData\Roaming\npm\node_modules\cordova\bin\cordovacordova@5.4.1 C:\Users\user\AppData\Roaming\npm\node_modules\cordova├── underscore@1.7.0├── q@1.0.1├── ansi@0.3.0├── nopt@3.0.1 (abbrev@1.0.7)├── update-notifier@0.5.0 (is-npm@1.0.0, semver-diff@2.1.0, repeating@1.1.3,string-length@1.0.1, chalk@1.1.1, configstore@1.3.0, latest-version@1.0.1)└── cordova-lib@5.4.1 (valid-identifier@0.0.1, opener@1.4.1, properties-parser@0.2.3, semver@4.3.6, nopt@3.0.6, shelljs@0.3.0, rc@0.5.2, dep-graph@1.1.0, xcode@0.8.0, glob@4.0.6, npmconf@2.1.2, request@2.47.0, cordova-serve@1.0.0, aliasify@1.8.0, cordova-app-hello-world@3.10.0, init-package-json@1.9.1, tar@1.0.2, cordova-js@4.1.2, npm@2.14.14)

注: 如由于网络原因无法安装成功,可参看文章 《使用npm安装一些包失败了的看过来(npm国内镜像介绍)》

本文使用的是其中的方法一:

通过config命令

npm config set registry https://registry.npm.taobao.org npm info underscore


构建helloworld工程


步骤1:进入工作目录,并创建helloworld工程

C:\Users\user>d:D:\>cd cordovaD:\cordova>cordova create helloworldCreating a new cordova project.D:\cordova>

工程目录如下


步骤2:添加平台并验证

C:\Users\user>d:D:\>cd cordovaD:\cordova>cd helloworldD:\cordova\helloworld>cordova platform add browserAdding browser project...Running command: cmd "/s /c "C:\Users\user\.cordova\lib\npm_cache\cordova-browser\4.0.0\package\bin\create.bat D:\cordova\helloworld\platforms\browser io.cordova.hellocordova HelloCordova""Creating Browser project. Path: platforms\browserDiscovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the projectFetching plugin "cordova-plugin-whitelist@1" via npmInstalling "cordova-plugin-whitelist" for browserThis plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.D:\cordova\helloworld>cordova run browserRunning command: cmd "/s /c "D:\cordova\helloworld\platforms\browser\cordova\run.bat""Static file server running on port 8000 (i.e. http://localhost:8000)CTRL + C to shut downStatic file server running @ http://localhost:8000/index.htmlCTRL + C to shut downExecuting command: cmd /c start "" chrome --user-data-dir=%TEMP%\temp_chrome_user_data_dir_for_cordova http://localhost:8000/index.htmlgzip200 /index.html (D:\cordova\helloworld\platforms\browser\www\index.html)gzip200 /css/index.css (D:\cordova\helloworld\platforms\browser\www\css\index.css)gzip200 /cordova.js (D:\cordova\helloworld\platforms\browser\www\cordova.js)gzip200 /js/index.js (D:\cordova\helloworld\platforms\browser\www\js\index.js)gzip200 /img/logo.png (D:\cordova\helloworld\platforms\browser\www\img\logo.png)gzip200 /cordova_plugins.js (D:\cordova\helloworld\platforms\browser\www\cordova_plugins.js)404 /favicon.ico


0 0