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 tools
requires 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/CommandLineTools
Enter, if the folder exists, the installation is successful.
2. Install Node.js
1. The official download is here .
2. After installation, the folder Node
is placed /usr/local/bin/node
, and the folder npm
is 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-install
install, 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连接成功。
5. Close the game-server server
1. Enter game-server
the directory.
2. Use the pomelo stop
command to close.
3. | References