linux系統上搭建egret構建環境(針對5.3.x 版以上)

目的

在linux操做系統下,實現對基於egret 5.3.x引擎開發的項目進行構建。node

現狀

據公開的資料,egret官方只提供windows及Mac下的開發、構建方案。linux

正文

約束及環境

  • 本文假設讀者已經對linux操做系統至少有基本的概念,瞭解基礎的操做命令。
  • 本文實驗的操做系統環境爲:centos7, root帳號。(理論上系統版號號及帳號不會影響實驗效果。)

創建工做區

mkdir ~/egret-space

準備node環境

已經有node環境能夠跳過此步。
從node.js官網上下載合適的node版本,本文實驗用的包爲 10.23(白鷺官方代碼用到的node api應該仍是屬於node v8.x之前的)shell

# 進入工做區
    cd ~/egret-space

    # 下載 node 二進制包
    wget https://nodejs.org/dist/latest-v10.x/node-v10.23.0-linux-x64.tar.xz

    # 解壓縮
    tar -vxf node-v10.23.0-linux-x64.tar.xz

    # 爲node綁定環境變量
    vi /etc/bashrc

    # 在末屬加行
    export PATH=$PATH:/root/egret-space/node-v10.23.0-linux-x64/bin
    # 保存文件後更新
    source ~/.bashrc

    # 查看node版本,驗證上述步驟是不是否生效
    node -v

準備windows下的egret環境

準備linux下的egret環境

  • 準備engine目錄
mkdir ~/.egret/engine
    cd ~/.egret/
    npm init
    # 名字輸入egret
    # 而後一路回車
  • 添加引擎庫

在 /root/.egret/engine中放入具體的egret版本包(包來自於windows裏C:\Users\用戶名\AppData\Roaming\Egret\Engine\)npm

  • 爲egret綁定環境變量
vi /etc/bashrc
    # 在末尾加一行
    export EGRET_PATH /root/.egret

    # 編輯node環境那一步中 export PATH那行,在該行末加入 :/root/.egret/engine/5.3.10/tools/bin/
    # 保存刷新
    source ~/.bashrc
    # 驗證
    egret info
  • 安裝 egret-compiler
mkdir ~/.config/EgretLauncher/download/EgretCompiler
    # 將 windows 系統裏 C:\Users\用戶名\AppData\Roaming\EgretLauncher\download\EgretCompiler 下的 egret-compiler-0.0.4.zip
    # 上傳到 linux裏的 /root/.config/EgretLauncher/download/EgretCompiler 下,並解壓縮
    cd  ~/.config/EgretLauncher/download/EgretCompiler
    unzip egret-compiler-0.0.4.zip
  • 安裝 egret-library-installer
npm install @egret/egret-library-installer -g

建立項目驗證egret構建與發佈

cd ~/egret-space
    egret create test1

    cd ~/egret-space/test1
    # 構建
    egret build

    # 發佈
    egret publish

附:可能遇到的問題windows

  • 若是有全局安裝過egret(npm install egret -g),記得卸載一下(npm uninstall egret -g)
相關文章
相關標籤/搜索