1 安装依赖node.js
1.1 node 版本
C:\Users\**>node -v
v10.15.1
1.2 npm包管理工具版本(当前,node会同时安装npm)
C:\Users\**>npm -v
6.4.1
1.3 安装week-toolkit
C:\Users\**>npm install -g weex-toolkit
WINDOWS下安装weex-toolkit会出现以下警告: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\weex-toolkit\node_modules\xtoolkit\node_modules\fsevents)
weex -v查看安装weex版本:(此处需参考文章结尾的注意事项)
C:\Users\**>weex -v
? May weex-toolkit anonymously report usage statistics to improve the tool over time? No
? Which npm registry you perfer to use? npm
11:34:05 : Set telemetry => false
11:34:05 : Set registry => http://registry.npmjs.org
Set telemetry = false
Set registry = "http://registry.npmjs.org"
11:34:05 : You can config this configuration again by using `weex config [key] [value]`
11:34:05 : Enjoying your coding time!
v1.3.11
- weex-builder : v0.4.0
- weex-previewer : v1.5.1
1.4 weex init project
小技巧:window下快速切换盘符路径(cd /d P:\weex-project)
>weex init projectname
>..\\\\\
>
Success! Created day01 at P:\weex-project\day01
Inside that directory, you can run several commands:
npm start
Starts the development server for you to preview your weex page on browser
You can also scan the QR code using weex playground to preview weex page on native
npm run dev
Open the code compilation task in watch mode
npm run ios
(Mac only, requires Xcode)
Starts the development server and loads your app in an iOS simulator
npm run android
(Requires Android build tools)
Starts the development server and loads your app on a connected Android device or emulator
npm run pack:ios
(Mac only, requires Xcode)
Packaging ios project into ipa package
npm run pack:android
(Requires Android build tools)
Packaging android project into apk package
npm run pack:web
Packaging html5 project into `web/build` folder
npm run test
Starts the test runner
To get started:
cd day01
npm start
Enjoy your hacking time!
npm start 启动第一个hello word 项目:
参考链接:https://www.colabug.com/2018767.html(weex 环境搭建)
注意:在选择registry时强烈建议选择国内淘宝的,npm库国内网络连接很不稳定,我刚开始设置的npm库,但是weex安装未成功,后来把registry修改成淘宝的了,才可以成功安装weex;
registry = "https://registry.npm.taobao.org"