forked from marcwan/LearningNodeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mac_osx_from_source.rtf
144 lines (123 loc) · 4.05 KB
/
mac_osx_from_source.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340
{\fonttbl\f0\fswiss\fcharset0 ArialMT;\f1\fmodern\fcharset0 Courier;\f2\fnil\fcharset0 LucidaGrande;
}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww17560\viewh12320\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803
\f0\b\fs30 \cf0 Installing from Source on Mac OS X\
\b0\fs24 \
If you have Xcode on your Mac, you can also build and install Node.js from the source code.\
\
\b\fs26 0. Getting the Command-Line Compiler via Xcode\
\
\b0\fs24 To build Node.js from source on your OS X\'96based computer, you first need to make sure that you have the command-line compiler tools installed. To do this, you can type\
\
\f1 c++
\f0 \
\
in a terminal window. If you don\'92t know what a terminal window is, you should probably use the PKG installer method described previously for installing Node.js onto your Mac.\
\
If you see something like\
\
\f1 client:LearningNode marcw$ c++\
clang: error: no input files
\f0 \
\
you have the compiler installed and will be able to build. If instead you see\
\
\f1 client:LearningNode marcw$ c++\
-bash: c++: No such file or directory
\f0 \
\
you need to do the following:\
\
1. Launch Xcode.\
2. View Xcode Preferences (
\f2 \uc0\u8984 + ,
\f0 ).\
3. Select the Downloads page and Components group, and then click on Install or Update next to Command Line Tools.\
\
After these command-line tools are installed, the c++ command should work, and you should be able to continue compiling.\
\
\b\fs26 1. Building Node.js\
\b0\fs24 \
Start by creating some scratch space to download and compile from:\
\
\f1 cd\
mkdir -p src/scratch\
cd src/scratch\
\f0 \
The next step is to download and unpack the Node sources. You can do this using
\f1 curl
\f0 or
\f1 wget
\f0 :\
\
\f1 curl http://nodejs.org/dist/v0.10.1/node-v0.10.1.tar.gz -o node-v0.10.1.tar.gz\
tar xfz node-v0.10.1.tar.gz\
cd node-v0.10.1
\f0 \
\
Next, run the configuration scripts to prepare for the build:\
\
\f1 ./configure
\f0 \
\
You can let it use the default
\i /usr/local
\i0 as the installation point because it\'92s a good location from which to run this software. If you want to install it somewhere else, you can specify the
\f1 --prefix
\f0 switch to the configure script, as follows:\
\
\f1 ./configure --prefix =/opt/nodejs
\f0 \
\
The configure script should print out some JavaScript Object Notation (JSON) similar to the following:\
\
\f1 \{ 'target_defaults': \{ 'cflags': [],\
'default_configuration': 'Release',\
'defines': [],\
'include_dirs': [],\
'libraries': []\},\
'variables': \{ 'clang': 1,\
'host_arch': 'x64',\
'node_install_npm': 'true',\
'node_install_waf': 'true',\
'node_prefix': '',\
'node_shared_openssl': 'false',\
'node_shared_v8': 'false',\
'node_shared_zlib': 'false',\
'node_unsafe_optimizations': 0,\
'node_use_dtrace': 'false',\
'node_use_etw': 'false',\
'node_use_openssl': 'true',\
'target_arch': 'x64',\
'v8_no_strict_aliasing': 1,\
'v8_use_snapshot': 'true'\}\}\
creating ./config.gypi\
creating ./config.mk\
\f0 \
Now you can build the product. Type in the following command and go get yourself a coffee (or two, depending on how fast your machine is):\
\
\f1 make
\f0 \
\
After the make has completed successfully (if it fails, do a Google search on the problem because you will almost certainly not be the first to see it), you can then install the software to your chosen prefix (/usr/local if you did not choose one):\
\
\f1 sudo make install
\f0 \
\
When you are done, you should be able to just enter\
\
\f1 node --version\
npm --version\
\f0 \
and get output somewhat similar to\
\
\f1 client:node-v0.10.3 marcw$ node --version\
v0.10.3\
client:node-v0.10.3 marcw$ npm --version\
1.1.65
\f0 \
\
}