Simple tutorial on using Node. js in Mac OS
This article mainly introduces a simple tutorial on using Node. js in Mac OS. Node. js is a framework that allows JavaScript applications to run on the server. For more information, see
Here is a good article about Node. js Introduction Article great nodejs intro, which will give you a very convenient introduction to Node. js and CouchDB, and provide an instance to implement the REST service for performing the CRUD operation on bookmarks, using CouchDB as the database.
This article describes how to install and start using Node in Mac OS X. js. This process takes about 30 minutes. We will also install CouchDB and implement CouchDB-based REST APIs.
This document assumes that Git has been installed on your machine. If not, please refer to this article for installation.
Install node. js and npm
The simplest method is in node. on the official js website, go to the nodejs download section page and select the installation program under Mac. It will install Node on your machine. js and npm (node package manager ).
After the installation is successful, you can use the node and npm commands.
Install CouchDB
Because this article uses CouchDB to store objects, you also need to install CouchDB.
Installing CouchDB is a little troublesome, because we need to download the source code and then compile I. Before that, we need to install Homebrew. Please execute the following command:
?
1 2 3 4 |
Git clone https://github.com/mxcl/homebrew.git Cd homebrew/bin Brew install autoconf automake libtool Brew install couchdb |
Note: A problem reported before CouchDB may prevent installation. To fix this problem, you must manually edit it ~ The/couch/homebrew/Library/Formula/couchdb. rb file is edited as follows:
Copy the Code as follows:
Require 'formula'
Class Couchdb <Formula
Url 'HTTP: // www.apache.org/dyn/closer.cgi? Path = couchdb/source/1.1.1/apache-couchdb-1.1.1.tar.gz'
Homepage "http://couchdb.apache.org /"
Md5 'cd126219b9cb69a4c521abd6960807a6'
Note that you need to delete the source in the url. The final Modification result is as follows:
The Code is as follows:
Require 'formula'
Class Couchdb <Formula
Url 'HTTP: // www.apache.org/dyn/closer.cgi? Path = couchdb/1.1.1/apache-couchdb-1.1.1.tar.gz'
Homepage "http://couchdb.apache.org /"
Md5 'cd126219b9cb69a4c521abd6960807a6'
If the installation process is suspended, you need to terminate the CTRL-C and execute the following command to try again:
The Code is as follows:
./Brew install-v couchdb