ionic框架配置-創(chuàng)新互聯(lián)

ionic簡介

ionic是一個專注于用WEB開發(fā)技術(shù),基于HTML5創(chuàng)建類似于手機(jī)平臺原生應(yīng)用的一個開發(fā)框架。目前綁定的與angularJS和SASS。這個框架的目的是從web的角度開發(fā)手機(jī)應(yīng)用,基于PhoneGap的編譯平臺,可以實現(xiàn)編譯成各個平臺的應(yīng)用程序。

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站設(shè)計制作、做網(wǎng)站、仲巴網(wǎng)絡(luò)推廣、小程序開發(fā)、仲巴網(wǎng)絡(luò)營銷、仲巴企業(yè)策劃、仲巴品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們大的嘉獎;成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供仲巴建站搭建服務(wù),24小時服務(wù)熱線:028-86922220,官方網(wǎng)址:muchs.cn

ionic安裝

首先需要安裝cordova和android環(huán)境。這個參考:phoneGap之Android環(huán)境搭建,上面寫的很詳細(xì),還有常見的錯誤及解決辦法。
然后安裝ionic:

npm install -g ionic

如果因為網(wǎng)絡(luò)原因安裝不上有兩種辦法:

1.修改npm源為淘寶npm源,可以使用下面三種方法中的任意一種

A.通過config命令

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

npm info underscore (如果上面配置正確這個命令會有字符串response)

B.命令行指定

npm --registry https://registry.npm.taobao.org info underscore

C.編輯 ~/.npmrc 加入下面內(nèi)容

registry = https://registry.npm.taobao.org

2.拷貝安裝過的ionic目錄,配置環(huán)境變量或者建立軟連接。

安裝完成之后,就可以使用ionic創(chuàng)建項目了。

ionic start myApp tabs  //創(chuàng)建帶有top欄和bottom欄的示例項目

ionic start myApp sidemenu  //創(chuàng)建帶有左側(cè)帶有menu欄的示例項目

ionic start myApp blank  //創(chuàng)建空白項目

具體效果,可以查看官網(wǎng): http://ionicframework.com/getting-started/
然后可以使用:

ionic serve

該命令會自動啟動流瀏覽器,查看當(dāng)前效果。

添加Android平臺

執(zhí)行下面的命令,

cd myApp
ionic platform add android //這行可能會報錯
ionic build android
ionic emulate android

其實上面的使用方法和cordova差不多,添加android的時候可能會報錯,如下:

The error is: ======================================= events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:1000:11) at Process.ChildProcess._handle.onexit (child_process.js:791:34)

解決的方法很簡單,將ionic換成cordova即可,經(jīng)測試works fine。

cd myApp
cordova platform add android //這行可能會報錯
cordova build android
cordova emulate android

其他常見錯誤

  1. 生成項目(ionic start myApp tabs)時可能會報錯,如下:

Error: command failed:fatal:could not create work tree dir:'C:\Users/ADMINI~1\AppData\Local\Temp\plugman\git\1402853493773'.:No such file or directory

解決辦法:進(jìn)入上面對應(yīng)的目錄,建立對應(yīng)的文件。比如在temp目錄下建立plugman目錄,在plugman目錄下建立git目錄,然后再git下建立1402853493773目錄。即可,經(jīng)測試有效。

2.sh: 1: node-gyp: Permission denied 安裝軟件包報錯
這個一般是centos等系統(tǒng),在root用戶下安裝會報錯。主要是權(quán)限問題,報錯詳情:

> node-gyp rebuild

sh: 1: node-gyp: Permission denied
\
> ws@0.4.32 install /root/.nvm/versions/node/v0.12.4/lib/node_modules/log.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

> ws@0.4.32 install /root/.nvm/versions/node/v0.12.4/lib/node_modules/log.io/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

npm ERR! Linux 3.13.0-48-generic
npm ERR! argv "/root/.nvm/versions/node/v0.12.4/bin/node" "/root/.nvm/versions/node/v0.12.4/bin/npm" "install" "-g" " log.io"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! contextify@0.1.14 install: `node-gyp rebuild`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the contextify@0.1.14 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log

可以清楚看到訊息中提示我們在執(zhí)行node-gyp 的時候權(quán)限不足。

查詢一下Google ,找到別人blog寫得簡單解決方法:

npm config set unsafe-perm true

接下來安裝就正常了。 至于npm config的使用方法, 請參考 此處 .
我們可以從npm config set unsafe-perm的解說中看到,我們剛剛修改的意思。

Default: false if running as root, true otherwise
Type: Boolean
Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

網(wǎng)頁名稱:ionic框架配置-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://muchs.cn/article48/deioep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷企業(yè)網(wǎng)站制作、Google、品牌網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)