🎉 server setup easy-mok can be read this article

Why build your own easy-mock?

Himself has recently been sharing the front-end sweet small white series of tutorials, share to eighth article already, so we have to get to the next phase project and case sharing, involves data interaction and background, then the problem comes, as a front-end developer siege lion can’t write the background data, only local false data, and the actual enterprise development gap is bigger, in order to simulate the enterprise actual development To help you write your own API data, we recommend you to use the easy-mock tool to create API data interface, but the official website is www.easy-mock.com/ Because it is open, many people use it, and it often fails to enter. Fortunately, the official source code is open, so we can build a set of easy-mock locally or on the server. Here I will share the Easy Mock built locally on the Mac system.

There are two ways to install easy-mock:

  • 1. ByHomebrew
  • 2. Configure it manually

Homebrew has not been successful, so this article shares a manual installation.

I. System environment

  • Apple (Mac)
  • Redis – 5.0.2
  • Mongo osx – SSL – x86_64-4.0.4
  • Easy to mock the latest version
  • Node 8.9.1 (NVM is recommended to manage node versions)

2. Install node version management NVM (skip this step if you have installed it)

  • 1. Enable terminal inputThe curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
  • 2. ByviorvimCommand to open the.bash_profileAnd add the following code if not.bash_profileFile then create one yourself
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" 
# This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  
# This loads nvm bash_completion
Copy the code

Vi. Bash_profile Open the file and press I to enter edit mode, copy the above code to the editor, then press Esc to exit, then press Shift: enter wq and save

Normally, after the installation, we will type NVM -v to see if it is really installed. As a result… Unfortunately, it says:

command not found: nvm
Copy the code

Do not worry if you encounter the above error, the reason is that what you just added to.bash_profile did not take effect.

source .bash_profile
Copy the code

If that still doesn’t work, suggest the following

Touch ~ /. Following the curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bashCopy the code

Install Node 8.9.1 through NVM install 8.9.1

Install Redis

Download the download. Redis. IO/releases/re… Go to CD Desktop/ and move the decompressed file to /usr/local/redis

Enter the following command:

Sudo mv redis - 5.0.2 / usr /local/redis
cd /usr/local/redis
sudo make test
sudo make install
redis-server
Copy the code

If you see the image below, your Redis installation is successful!

Install the mongo

Download fastdl.mongodb.org/osx/mongodb… And unzip to the desktop

Go to the desktop directory and execute:

Sudo mv mongo - osx - x86_64-4.0.4 / usr /local/mongodb
Copy the code

Add environment variables to the.bash_profile(if not created) file

export PATH=/usr/local/mongodb/bin:${PATH}
Copy the code

Then execute:

source ~/.bash_profile
Copy the code

Create the /mongodb/data/db folder

sudo mkdir -p /mongodb/data/db

Copy the code

Note: Ifsudo mkdir -p /mongodb/data/dbThis method is not successful, recommendedsudo mkdirCreate folders layer by layer

Go to /usr/local/mongodb/bin in the mongodb installation directory

. / mongod -- -- dbpath/Users/frru/mongo/data/db/mongo / / if it is to start again, don't need itCopy the code

Install easy mock

git clone https://github.com/easy-mock/easy-mock.git
cd easy-mock && npm install
Copy the code

Start: Execute in the easy-Mock project directory

NVM use 8.9.1 NPM run devCopy the code

Five, access to view the effect

http://localhost:7300

And you’re done!

Reference connection:

www.jianshu.com/p/8c40dbda6…

www.imooc.com/article/det…

Welcome friends to comment and forward, remember to like 👍 to encourage!

Scan the following TWO-DIMENSIONAL code, reply learning can be free to receive the latest front-end learning materials, but also hope that in the way of front-end advancement, we grow together, progress together!