`

how to Installing Node and community add-ons

阅读更多

Node can either be installed using conventional application installers or by using the command line. Command-line installation is easy on OS X and Linux, but it’s not recommended for Windows.

 

A.1. OS X setup

The official installer provides an easy way to install a precompiled version of Node and npm.

Installation with Homebrew
//Install Homebrew by entering the following into the command line
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

//Install Node
brew install node

 

A.2. Windows setup

Node can be most easily installed on Windows by using the official standalone installer. After installing, you’ll be able to run Node and npm from the Windows command line. If you want install it by source code, you may need Cygwin to run Node. Cygwin’s package selector allows you to select open source software that will be installed on your system.

Cygwin packages needed to run Node
devel gcc4-g++
devel git
devel make
devel openssl-devel
devel pkg-config
devel zlib-devel
net inetutils
python python
web wget

 Once you’ve selected the packages, click Next. run Cygwin and compile Node.

 

A.3. Linux setup

there are other installation instructions on GitHub:

Ubuntu installation prerequisites
//Before installing Node on Ubuntu, you’ll need to install prerequisite packages. This is done on Ubuntu 11.04 or later using a single command:
sudo apt-get install build-essential libssl-dev

 

CentOS installation prerequisites
//Before installing Node on CentOS, you’ll need to install prerequisite packages. This is done on CentOS 5 using the following commands:
sudo yum groupinstall 'Development Tools'
sudo yum install openssl-devel

 

Compiling Node involves the same steps on all operating systems.

Compiling Node
//create a template file to download node source code
>mkdir tmp
>cd tmp
>curl -O http://nodejs.org/dist/node-latest.tar.gz
>tar zxvf node-latest.tar.gz
>ls
>cd node-v*
>./configure
>make
>sudo make install
>node -v

if you run Cygwin On Windows 7 or Vista,it maybe have errors。this is because of Cygwin.Just quit Cygwin enviroment,run ash.exe(c:\cygwin\bin\ash.exe), and enter /bin/rebaseall -v。then restart your computer.

 You should now have Node on your machine!

 

Using the Node Package Manager

The Node stack is composed of globally available functionality, core modules, and community-created modules.


npm is missing on my system
cd /tmp
git clone git://github.com/isaacs/npm.git
cd npm
sudo make install
npm -v

  

Searching for packages

//search for xml packages
npm search xml generator

 or you can use http://search.npmjs.org/  to search the info. The npm search website provides useful statistics on module popularity.

Installing packages
//installing the express package locally:
> npm install express
//installing the express package globally:
>npm install -g express
//or
>sudo npm install -g express

 

Exploring documentation and package code
//an example of viewing documentation for the express package:
>npm docs express
//explore the local express source code
>npm explore express
//explore the global express source code
>npm -g explore express

 

 

 

 

 

  • 大小: 16.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics