距离阿里勾股宣布weex开源已经过去了6个月了,在2016年最后一天,让我来实践下weex的魅力,首先通过githua上weex的文档介绍到,该框架依赖于nodejs,so,我们需要安装下nodejs。
- 安装nodejs
- 安装weex
$ npm install -g npm
$ npm install -g node-gyp
$ npm install -g weex-toolkit
按照官方文档,在这一步控制台输入weex,预计得到的效果是:
Usage: weex foo/bar/we_file_or_dir_path [options]
Usage: weex debug [options] [we_file|bundles_dir]
Usage: weex init
Options:
--qr display QR code for PlaygroundApp [boolean]
--smallqr display small-scale version of QR code for PlaygroundApp,try it
if you use default font in CLI [boolean]
-o, --output transform weex we file to JS Bundle, output path must specified
(single JS bundle file or dir)
[for create sub cmd]it specified we file output path
[default: "no JSBundle output"]
--watch using with -o , watch input path , auto run transform if change
happen
-s, --server start a http file server, weex .we file will be transforme to JS
bundle on the server , specify local root path using the option
[string]
--port http listening port number ,default is 8081 [default: -1]
--wsport websocket listening port number ,default is 8082 [default: -1]
--np do not open preview browser automatic [boolean]
-f, --force [for create sub cmd]force to replace exsisting file(s) [boolean]
--help Show help [boolean]
-h, --host [default: "127.0.0.1"]
weex debug -h for Weex debug help information.
for cmd example & more information please visit
https://www.npmjs.com/package/weex-toolkit
等等,不是输出的不是这个内容啊
module.js:471
throw err;
^
Error: Cannot find module 'koa-bodyparser'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\homeant\AppData\Roaming\npm\node_modules\weex-toolkit\node_modules\weex-devtool\lib\DebugServer.js:9:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\homeant\AppData\Roaming\npm\node_modules\weex-toolkit\node_modules\weex-devtool\index.js:14:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
感觉被坑了有木有,不过细心的小伙伴已经发现问题了,控制台告诉你,缺少koa-bodyparser这个模块,好吧,我们安装一下:
$ npm install -g koa-bodyparser
这次终于成功了。