Recently set up the NODEJS environment on Mac and install Express framework, encountered some problems, but finally installed successfully, the following is the procedure
1.node JS Installation
Visit Nodejs website to download the installation package on the Mac, download here can choose Mac Installer pkg installation package, download directly click on the installation, of course, you can also choose binary package for installation, download and then use the TAR-ZXVF command to unpack and then edit In the installation. The new version of the installer will install NPM (Nodejs's package management tool) and test if the installation is successful.
Use Node-v and npm-v to view the respective version information, if the node command can not find the first to use the which node command to see the installation directory, and then you can use the
Second, you can follow the Nodejs homepage to provide the demo JS script, write a Hello World program, and then visit in the browser to see if OK, to here Node JS installation is complete
2.express Installation
Express is a framework for node JS, which provides many components that facilitate the rapid development of Nodejs. This is similar to some quick frameworks for other languages, PHP Yii,yp, SSH in Java.
When installing Express, you can also refer to the Getting started step of the Express website to install, but I follow this is not installed up.
Now the latest Express version is more than 4.0, express4.0 later version of the Express command line tool from the Express Library separated out (Https://github.com/expressjs/generator) , the way it was installed also changed. has been used before
NPM Istall-g Express
This command tool installs and displays success, but the command line cannot be used for express.
Now for a global installation, choose whether to install globally, depending on your needs. The command is as follows
Install
When the express command-line tool above is installed, you can install the Express framework
cd/var/www/&& CD Test// Install Express frame relies on install// Start test this project NPM start
Do not use node app.js this way when it is started here, you can use the VIM command to see the contents of the Package.json file in the test directory, where scripts line is found
Then visit http://localhost:3000, you can see Welcome Express!!!
Here we go.
Nodejs Express installation on Mac