os: windows 10
node: 7.4.0
1. node.js를 시작할 폴더의 경로를 지정하여 다음의 명령어를 실행합니다.
npm은 프로젝트 구성을 위해 몇 가지 파라미터를 요청하므로 적절히 입력 후 엔터
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 | C:\Users\Admin\Downloads\node>npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (node) rabbit version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: author: license: (ISC) About to write to C:\Users\Admin\Downloads\node\package.json: { "name": "rabbit", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" } Is this ok? (yes) yes | cs |
2. 2~3번 과정은 추후 사용할 프레임워크 및 툴이므로 필요치 않을 경우 하지 않아도 무방합니다.
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 | C:\Users\Admin\Downloads\node>npm install --save seneca rabbit@1.0.0 C:\Users\Admin\Downloads\node `-- seneca@3.6.0 +-- archy@1.0.0 +-- eraro@1.0.0 +-- gate-executor@1.1.1 +-- gex@0.3.0 +-- json-stringify-safe@5.0.1 +-- jsonic@0.3.0 +-- lodash@4.17.10 +-- minimist@1.2.0 +-- nid@0.3.2 +-- norma@0.4.1 +-- ordu@0.1.1 +-- patrun@1.0.0 +-- qs@6.5.2 +-- rolling-stats@0.1.1 +-- semver@5.5.0 +-- seneca-transport@2.3.0 | +-- lru-cache@4.1.3 | | +-- pseudomap@1.0.2 | | `-- yallist@2.1.2 | +-- ndjson@1.5.0 | | +-- split2@2.2.0 | | `-- through2@2.0.3 | | +-- readable-stream@2.3.6 | | | +-- core-util-is@1.0.2 | | | +-- inherits@2.0.3 | | | +-- isarray@1.0.0 | | | +-- process-nextick-args@2.0.0 | | | +-- safe-buffer@5.1.2 | | | +-- string_decoder@1.1.1 | | | `-- util-deprecate@1.0.2 | | `-- xtend@4.0.1 | `-- reconnect-core@1.3.0 | `-- backoff@2.5.0 | `-- precond@0.2.3 +-- use-plugin@1.0.2 `-- wreck@12.5.1 +-- boom@5.2.0 `-- hoek@4.2.1 npm WARN rabbit@1.0.0 No description npm WARN rabbit@1.0.0 No repository field. | cs |
3.
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | C:\Users\Admin\Downloads\node>npm install -g pm2 C:\Users\Admin\AppData\Roaming\npm\pm2-runtime -> C:\Users\Admin\AppData\Roaming\npm\node_modules\pm2\bin\pm2-runtime C:\Users\Admin\AppData\Roaming\npm\pm2-dev -> C:\Users\Admin\AppData\Roaming\npm\node_modules\pm2\bin\pm2-dev C:\Users\Admin\AppData\Roaming\npm\pm2-docker -> C:\Users\Admin\AppData\Roaming\npm\node_modules\pm2\bin\pm2-docker C:\Users\Admin\AppData\Roaming\npm\pm2 -> C:\Users\Admin\AppData\Roaming\npm\node_modules\pm2\bin\pm2 C:\Users\Admin\AppData\Roaming\npm `-- pm2@2.10.4 +-- async@2.6.1 | `-- lodash@4.17.10 +-- blessed@0.1.81 +-- chalk@1.1.3 | +-- ansi-styles@2.2.1 | +-- escape-string-regexp@1.0.5 | +-- has-ansi@2.0.0 | | `-- ansi-regex@2.1.1 | +-- strip-ansi@3.0.1 | `-- supports-color@2.0.0 +-- chokidar@2.0.3 | +-- anymatch@2.0.0 | | `-- micromatch@3.1.10 | | +-- arr-diff@4.0.0 | | +-- define-property@2.0.2 | | | `-- is-descriptor@1.0.2 | | | +-- is-accessor-descriptor@1.0.0 | | | `-- is-data-descriptor@1.0.0 | | +-- extend-shallow@3.0.2 | | | +-- assign-symbols@1.0.0 | | | `-- is-extendable@1.0.1 | | | `-- is-plain-object@2.0.4 | | +-- extglob@2.0.4 | | | +-- define-property@1.0.0 | | | | `-- is-descriptor@1.0.2 | | | | +-- is-accessor-descriptor@1.0.0 | | | | `-- is-data-descriptor@1.0.0 | | | +-- expand-brackets@2.1.4 | | | | +-- debug@2.6.9 | | | | +-- define-property@0.2.5 | | | | +-- extend-shallow@2.0.1 | | | | `-- posix-character-classes@0.1.1 | | | `-- extend-shallow@2.0.1 | | +-- fragment-cache@0.2.1 | | +-- kind-of@6.0.2 | | +-- nanomatch@1.2.9 | | | +-- is-odd@2.0.0 | | | | `-- is-number@4.0.0 | | | `-- is-windows@1.0.2 | | +-- object.pick@1.3.0 | | `-- regex-not@1.0.2 | +-- async-each@1.0.1 | +-- braces@2.3.2 | | +-- arr-flatten@1.1.0 | | +-- array-unique@0.3.2 | | +-- extend-shallow@2.0.1 | | | `-- is-extendable@0.1.1 | | +-- fill-range@4.0.0 | | | +-- extend-shallow@2.0.1 | | | +-- is-number@3.0.0 | | | | `-- kind-of@3.2.2 | | | | `-- is-buffer@1.1.6 | | | +-- repeat-string@1.6.1 | | | `-- to-regex-range@2.1.1 | | +-- isobject@3.0.1 | | +-- repeat-element@1.1.2 | | +-- snapdragon@0.8.2 | | | +-- base@0.11.2 | | | | +-- cache-base@1.0.1 | | | | | +-- collection-visit@1.0.0 | | | | | | +-- map-visit@1.0.0 | | | | | | `-- object-visit@1.0.1 | | | | | +-- get-value@2.0.6 | | | | | +-- has-value@1.0.0 | | | | | | `-- has-values@1.0.0 | | | | | | `-- kind-of@4.0.0 | | | | | +-- set-value@2.0.0 | | | | | | `-- extend-shallow@2.0.1 | | | | | +-- to-object-path@0.3.0 | | | | | | `-- kind-of@3.2.2 | | | | | +-- union-value@1.0.0 | | | | | | `-- set-value@0.4.3 | | | | | | `-- extend-shallow@2.0.1 | | | | | `-- unset-value@1.0.0 | | | | | `-- has-value@0.3.1 | | | | | +-- has-values@0.1.4 | | | | | `-- isobject@2.1.0 | | | | +-- class-utils@0.3.6 | | | | | +-- arr-union@3.1.0 | | | | | +-- define-property@0.2.5 | | | | | `-- static-extend@0.1.2 | | | | | +-- define-property@0.2.5 | | | | | `-- object-copy@0.1.0 | | | | | +-- copy-descriptor@0.1.1 | | | | | +-- define-property@0.2.5 | | | | | `-- kind-of@3.2.2 | | | | +-- component-emitter@1.2.1 | | | | +-- define-property@1.0.0 | | | | | `-- is-descriptor@1.0.2 | | | | | +-- is-accessor-descriptor@1.0.0 | | | | | `-- is-data-descriptor@1.0.0 | | | | +-- mixin-deep@1.3.1 | | | | | +-- for-in@1.0.2 | | | | | `-- is-extendable@1.0.1 | | | | `-- pascalcase@0.1.1 | | | +-- debug@2.6.9 | | | +-- define-property@0.2.5 | | | | `-- is-descriptor@0.1.6 | | | | +-- is-accessor-descriptor@0.1.6 | | | | | `-- kind-of@3.2.2 | | | | +-- is-data-descriptor@0.1.4 | | | | | `-- kind-of@3.2.2 | | | | `-- kind-of@5.1.0 | | | +-- extend-shallow@2.0.1 | | | +-- map-cache@0.2.2 | | | +-- source-map@0.5.7 | | | +-- source-map-resolve@0.5.2 | | | | +-- atob@2.1.1 | | | | +-- decode-uri-component@0.2.0 | | | | +-- resolve-url@0.2.1 | | | | +-- source-map-url@0.4.0 | | | | `-- urix@0.1.0 | | | `-- use@3.1.0 | | +-- snapdragon-node@2.1.1 | | | +-- define-property@1.0.0 | | | | `-- is-descriptor@1.0.2 | | | | +-- is-accessor-descriptor@1.0.0 | | | | `-- is-data-descriptor@1.0.0 | | | `-- snapdragon-util@3.0.1 | | | `-- kind-of@3.2.2 | | +-- split-string@3.1.0 | | `-- to-regex@3.0.2 | | `-- safe-regex@1.1.0 | | `-- ret@0.1.15 | +-- glob-parent@3.1.0 | | +-- is-glob@3.1.0 | | `-- path-dirname@1.0.2 | +-- inherits@2.0.3 | +-- is-binary-path@1.0.1 | | `-- binary-extensions@1.11.0 | +-- is-glob@4.0.0 | | `-- is-extglob@2.1.1 | +-- normalize-path@2.1.1 | | `-- remove-trailing-separator@1.1.0 | +-- path-is-absolute@1.0.1 | +-- readdirp@2.1.0 | | +-- graceful-fs@4.1.11 | | +-- minimatch@3.0.4 | | | `-- brace-expansion@1.1.11 | | | +-- balanced-match@1.0.0 | | | `-- concat-map@0.0.1 | | +-- readable-stream@2.3.6 | | | +-- core-util-is@1.0.2 | | | +-- isarray@1.0.0 | | | +-- process-nextick-args@2.0.0 | | | +-- safe-buffer@5.1.2 | | | +-- string_decoder@1.1.1 | | | `-- util-deprecate@1.0.2 | | `-- set-immediate-shim@1.0.1 | `-- upath@1.1.0 +-- cli-table-redemption@1.0.1 +-- commander@2.13.0 +-- cron@1.3.0 | `-- moment-timezone@0.5.18 +-- debug@3.1.0 | `-- ms@2.0.0 +-- eventemitter2@1.0.5 +-- fclone@1.0.11 +-- gkt@1.0.0 +-- mkdirp@0.5.1 | `-- minimist@0.0.8 +-- moment@2.22.2 +-- needle@2.2.1 | +-- debug@2.6.9 | +-- iconv-lite@0.4.23 | | `-- safer-buffer@2.1.2 | `-- sax@1.2.4 +-- nssocket@0.6.0 | +-- eventemitter2@0.4.14 | `-- lazy@1.0.11 +-- pidusage@1.2.0 +-- pm2-axon@3.1.0 | +-- amp@0.3.1 | +-- amp-message@0.1.2 | `-- escape-regexp@0.0.1 +-- pm2-axon-rpc@0.5.1 +-- pm2-deploy@0.3.9 | +-- async@1.5.2 | `-- tv4@1.3.0 +-- pm2-multimeter@0.1.2 | `-- charm@0.1.2 +-- pmx@1.6.7 | +-- deep-metrics@0.0.1 | +-- json-stringify-safe@5.0.1 | `-- vxx@1.2.2 | +-- continuation-local-storage@3.2.1 | | +-- async-listener@0.6.9 | | `-- emitter-listener@1.1.1 | +-- debug@2.6.9 | +-- extend@3.0.1 | +-- is@3.2.1 | +-- lodash.findindex@4.6.0 | +-- lodash.isequal@4.5.0 | +-- lodash.merge@4.6.1 | +-- methods@1.1.2 | +-- shimmer@1.2.0 | `-- uuid@3.2.1 +-- promptly@2.2.0 | `-- read@1.0.7 | `-- mute-stream@0.0.7 +-- semver@5.5.0 +-- shelljs@0.7.8 | +-- glob@7.1.2 | | +-- fs.realpath@1.0.0 | | +-- inflight@1.0.6 | | | `-- wrappy@1.0.2 | | `-- once@1.4.0 | +-- interpret@1.1.0 | `-- rechoir@0.6.2 | `-- resolve@1.8.1 | `-- path-parse@1.0.5 +-- source-map-support@0.5.6 | +-- buffer-from@1.1.0 | `-- source-map@0.6.1 +-- sprintf-js@1.1.1 +-- v8-compile-cache@1.1.2 +-- vizion@0.2.13 | `-- async@1.5.2 `-- yamljs@0.3.0 `-- argparse@1.0.10 `-- sprintf-js@1.0.3 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.1.2 (node_modules\pm2\node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) | cs |
4. 해당 폴더에 app.js 파일 작성
5. app.js 코드
1 2 3 4 5 6 7 8 9 | var http = require('http'); var server = http.createServer(function(request, response) { response.writeHead(200, { "Content-Type": "text/plain" }); response.end("Hello World\n"); }); server.listen(8000); | cs |
6. 웹 브라우저에서 출력 확인
* 브라우저의 환경에 따라 "localhost:8000" 으로 접속되지 않을 경우 "http://127.0.0.1:8000/" 를 입력합니다.
'Programming > Node.js' 카테고리의 다른 글
node-v10.12.0-x64 설치 및 환경 구축 (0) | 2018.10.20 |
---|---|
node-v7.4.0-x64 설치 및 환경 구축 (0) | 2017.01.24 |