天天看點

weex學習 建立打包第一個weex項目 web和iOS的步驟

官方版本https://weex.apache.org/zh/guide/develop/create-a-new-app.html#初始化

感覺講的還是比較清楚的。

這裡總結一下內建遇到的問題。

建立一個新項目流程

cd 到目錄

weex create my-project

cd my-project

npm install
           

有個警告([email protected] requires a peer of [email protected] || 2 || ^2.1.0-beta || ^2.2.0-rc but none is installed. You must install peer dependencies yourself.)可忽略

npm start

如果報這個錯誤(npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] serve: `webpack-dev-server --env.NODE_ENV=development --progress` npm ERR! Exit status 1)

端口号被占用、重新開機終端即可。

網上查了關閉終端方法(https://blog.csdn.net/mingzznet/article/details/38345875)

先lsof -i:8080查找到端口号

lsof -i:8080
           

然後kill -9 15521

kill -9 15521
           

實際上我關閉了終端重新開機後就可以了。

打包成web

執行npm run pack:web就會有一個release檔案夾,裡面的html打開即可。

npm run pack:web
           

記錄下運作完給的執行說明

包括其他平台,ios,安卓,web

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 my-project
  npm start