Install pomelo under mac

1. | Installation necessary items

1. Install Xcode and related tools

1. Install Xcode .

2. Install the corresponding version of command line tools .

The download command line toolsrequires an Apple account, if you don't have one, it's OK to register one.


Tip : Command + shift + g in the desktop state (that is, open the Go to Folder window), enter /Library/Developer/CommandLineToolsEnter, if the folder exists, the installation is successful.


2. Install Node.js

1. The official download is here .

2. After installation, the folder Nodeis placed /usr/local/bin/node, and the folder npmis placed /usr/local/bin/npm. Normally $PATH(in the PATH of the environment variable) there should be a path /usr/local/bin.

3. Install pomelo

1. Open the terminal and switch to root privileges

$ sudo -i

After pressing Enter, you need to enter the local user password (that is, the computer login password).

2. Install the pomelo project

First go to the directory that needs to be installed, for example:

$ cd /Users/apple/Documents/WorkSpace

Install

$ npm install pomelo -g

》  Possible errors

1. Error message:

xcrun: error: active developer path
("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use
xcode-select to change 

2. Solution:

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer 

Reference source: Using gcc command on mac pro


II. | pomelo HelloWorld project

1. Create a project

Create a new HelloWorld project in the current directory

$ pomelo init ./HelloWorld

Second, install the necessary two npm dependent libraries express and crc

Every time you create a new project, you need to install the dependency library.

1. Switch to the directory where HelloWorld is located

$ cd /private/var/root/HelloWorld

2. Install dependent library files

$ sh npm-install.sh

You can use the above file to npm-installinstall, or you can download these two dependent libraries yourself. The download speed of the above method may be a bit slow, you can set it yourself. The method set by yourself has not been tried yet, and readers can explore it by themselves.

3. Start the game-server server

1、进入game-server目录

$ cd game-server

2、启动game-server

$ pomelo start

》 可能出现的错误

1、错误提示

    throw err;
          ^

Error: Cannot find module 'pomelo'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/apple/Documents/WorkSpace/Cocos2d-x/Projects/HelloWorld/game-server/app.js:1:76)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10) 

2、解决方法
/usr/local/lib/node_modules/路径下新建文件夹pomelo 在相应位置创建pomelo文件夹。如果没有添加依赖库也会出现此类错误。


四、启动web-server服务器:

终端进行新建窗口后输入

$ sudo -i
$ cd /private/var/root/HelloWorld/web-server
$ node app 

启动后会给出一个ip地址,例如:http://127.0.0.1:3001/index.html这个地址可以更改具体更改方法详见 官方:使用 WebStorm IDE 调试 Pomelo 应用程序

在浏览器中输入上述 ip,点击Test Game Server后弹出如下对话框说明HelloWorld连接成功

<iframe id="iframe_0.9295181375928223" style="margin: 0px; padding: 0px; border-style: none; width: 630px; height: 555px;" src="data:text/html;charset=utf8,%3Cstyle%3Ebody%7Bmargin:0;padding:0%7D%3C/style%3E%3Cimg%20id=%22img%22%20src=%22https://github.com/NetEase/pomelo/wiki/images/helloworld_test_snapshot.png?_=3979347%22%20style=%22border:none;max-width:669px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.9295181375928223',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no"></iframe>

5. Close the game-server server

1. Enter game-serverthe directory.

2. Use the pomelo stopcommand to close.

3. | References

一、官方:安装pomelo

二、官方:pomelo wiki(中文版)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326424577&siteId=291194637