{"id":4160,"date":"2013-01-14T19:54:19","date_gmt":"2013-01-14T10:54:19","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=4160"},"modified":"2013-01-14T19:57:10","modified_gmt":"2013-01-14T10:57:10","slug":"%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%b5%e3%82%a4%e3%83%89javascript-node-js-express%e3%82%84%e3%82%89npm%e3%82%84%e3%82%89","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=4160","title":{"rendered":"\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9Javascript node.js express\u3084\u3089npm\u3084\u3089"},"content":{"rendered":"<p>\u524d\u56de\u306e\u3001<a href=\"https:\/\/www.webcyou.com\/?p=4149\">\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9Javascript \u300enode.js\u300f mac\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u4f7f\u7528\u65b9\u6cd5<\/a>\u306e\u7d9a\u304d\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>node.js\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u3057\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001<\/p>\n<p>\u66f4\u306b\u4fbf\u5229\u306b\u4f7f\u3046\u70ba\u3001\u300cnpm\uff08Node Package Manager\uff09\u300d\u3092\u5229\u7528\u3057\u3001<\/p>\n<p>\u300cexpress\u300d\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>npm<\/strong><\/p>\n<p><a href=\"https:\/\/npmjs.org\" target=\"_blank\">https:\/\/npmjs.org<\/a><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6a373317caccf2ad4fae6703f0e850df.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6a373317caccf2ad4fae6703f0e850df.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-01-14 19.07.04\" width=\"523\" height=\"271\" class=\"alignnone size-full wp-image-4162\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/6a373317caccf2ad4fae6703f0e850df.png 523w, https:\/\/www.webcyou.com\/wp-content\/uploads\/6a373317caccf2ad4fae6703f0e850df-300x155.png 300w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><\/a><\/p>\n<p><strong>express<\/strong><\/p>\n<p><a href=\"http:\/\/expressjs.com\" target=\"_blank\">http:\/\/expressjs.com<\/a><\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/41e00aa74b7a6bd9e8d1268102bd708e.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/41e00aa74b7a6bd9e8d1268102bd708e.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-01-14 19.10.16\" width=\"419\" height=\"237\" class=\"alignnone size-full wp-image-4161\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/41e00aa74b7a6bd9e8d1268102bd708e.png 419w, https:\/\/www.webcyou.com\/wp-content\/uploads\/41e00aa74b7a6bd9e8d1268102bd708e-300x169.png 300w\" sizes=\"auto, (max-width: 419px) 100vw, 419px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>node.js\u306eweb\u30b5\u30a4\u30c8\u304b\u3089\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5834\u5408\u3001<\/p>\n<p>npm\uff08Node Package Manager\uff09\u3082\u5229\u7528\u51fa\u6765\u308b\u72b6\u614b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm -v<\/pre>\n<p>\u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u8868\u793a\u3059\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u3066\u3044\u308b\u72b6\u614b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">curl http:\/\/npmjs.org\/install.sh | sh<\/pre>\n<p>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u5f53\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u306a\u3044\u5834\u5408\u306f\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">sudo curl http:\/\/npmjs.org\/install.sh | sh<\/pre>\n<p>\u3053\u3061\u3089\u3067\u3088\u3044\u306e\u304b\u306a\u3002\u3002<\/p>\n<p>\u518d\u3073\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm -v<\/pre>\n<p>\u3067\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u8868\u793a\u3059\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u3066\u3044\u308b\u72b6\u614b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4><strong>express \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/h4>\n<p>express\u3092npm\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm install -g express<\/pre>\n<p>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002\uff08express\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3002express\u306e\u5834\u5408\u306a\u306e\u3067express\uff09<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3-g\u304c\u306a\u3044\u3068\u3001\u5b9f\u884c\u3057\u3066\u3044\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4e0b\u306b<\/p>\n<p>&#8220;node_modules&#8221;\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u308a\u3001\u305d\u3053\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u5165\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3-g\u3092\u4ed8\u3051\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u4e00\u5ea6\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u5168\u90e8\u306enode.js\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067<\/p>\n<p>\u4f7f\u3048\u308b\u3088\u3046\u306b\u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u9818\u57df\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u969b\u3001\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u3042\u308b\u3088\u3046\u306a\u306e\u3067\u3001<\/p>\n<p>\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3046\u5834\u5408\u306f\u3001<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">sudo npm install -g express<\/pre>\n<\/p>\n<p>sudo\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>password\u3092\u6c42\u3081\u3089\u308c\u307e\u3059\u306e\u3067\u3001PC\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3002\u30ea\u30bf\u30fc\u30f3\u3002<\/p>\n<h4><strong>express \u691c\u8a3c<\/strong><\/h4>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3089\u3001\u65e9\u901f\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>npm\u3067express\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5834\u5408\u3001express\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001<\/p>\n<p>\u4efb\u610f\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u767a\u884c\u3059\u308b\u3068\u3001\u65b0\u305f\u306bsample\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u4f5c\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">express example<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">create : example\r\ncreate : example\/package.json\r\ncreate : example\/app.js\r\ncreate : example\/public\r\ncreate : example\/routes\r\ncreate : example\/routes\/index.js\r\ncreate : example\/views\r\ncreate : example\/views\/layout.jade\r\ncreate : example\/views\/index.jade\r\ncreate : example\/public\/javascripts\r\ncreate : example\/public\/stylesheets\r\ncreate : example\/public\/stylesheets\/style.css\r\ncreate : example\/public\/images\r\n\r\ndont forget to install dependencies:\r\n$ cd example && npm install<\/pre>\n<p>express\u30b3\u30de\u30f3\u30c9\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u9aa8\u7d44\u307f\u3092\u4f5c\u3063\u3066\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u307e\u307e\u3060\u3068\u4f7f\u3048\u307e\u305b\u3093\u306e\u3067\u3001<\/p>\n<p>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306b\u3082\u8868\u793a\u3057\u3066\u3044\u308b\u3088\u3046\u306b\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">cd example<\/pre>\n<p>\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u79fb\u52d5\u3057\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">npm install<\/pre>\n<p>npm\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u3068\u3001\u3053\u306epackage.json\u304c\u8aad\u307f\u8fbc\u307e\u308c\u3066\u5fc5\u8981\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>node\u30b3\u30de\u30f3\u30c9\u3067app.js\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">node app.js<\/pre>\n<p>\u3059\u308b\u3068\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Express server listening on port 3000 in development mode<\/pre>\n<p>\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u306e\u3067\u3001http:\/\/127.0.0.1:3000\/\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001<\/p>\n<p>\u6b21\u306e\u3088\u3046\u306a\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u3068\u6210\u529f\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/e89c4171de7760d649491af04ebd849a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/e89c4171de7760d649491af04ebd849a.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-01-14 19.45.06\" width=\"309\" height=\"271\" class=\"alignnone size-full wp-image-4163\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/e89c4171de7760d649491af04ebd849a.png 309w, https:\/\/www.webcyou.com\/wp-content\/uploads\/e89c4171de7760d649491af04ebd849a-300x263.png 300w\" sizes=\"auto, (max-width: 309px) 100vw, 309px\" \/><\/a><\/p>\n<p><strong>routes\/index.js<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\/*\r\n* GET home page.\r\n*\/\r\nexports.index = function(req, res){\r\n res.render('index', { title: 'Express' });\r\n};<\/pre>\n<p><strong>views\/index.jade<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nextends layout\r\nblock content\r\nh1= title\r\np Welcome to #{title}<\/pre>\n<p>\u3053\u3061\u3089\u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u51fa\u529b\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3057\u305f\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u5909\u3048\u3066\u307f\u308b\u3068\u3001<\/p>\n<p>\u51fa\u529b\u3082\u5909\u66f4\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/d1838745d7183c27d3a54d6b2ff69eb7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/d1838745d7183c27d3a54d6b2ff69eb7.png\" alt=\"\" title=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2013-01-14 19.50.13\" width=\"360\" height=\"301\" class=\"alignnone size-full wp-image-4164\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/d1838745d7183c27d3a54d6b2ff69eb7.png 360w, https:\/\/www.webcyou.com\/wp-content\/uploads\/d1838745d7183c27d3a54d6b2ff69eb7-300x250.png 300w\" sizes=\"auto, (max-width: 360px) 100vw, 360px\" \/><\/a><\/p>\n<p>\u4ee5\u4e0a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5148<\/h4>\n<p><strong>node.js\u3092\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/p>\n<p>\/usr\/local\/bin<\/p>\n<p><strong>npm install \u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8<\/strong><\/p>\n<p>\/usr\/local\/lib\/node_modules<\/p>\n<p>\u306b\u683c\u7d0d\u3055\u308c\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306e\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9Javascript \u300enode.js\u300f mac\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u4f7f\u7528\u65b9\u6cd5\u306e\u7d9a\u304d\u3068\u306a\u308a\u307e\u3059\u3002 node.js\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u3057\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001 \u66f4\u306b\u4fbf\u5229\u306b\u4f7f\u3046\u70ba\u3001\u300cnpm\uff08Node Packag [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[168,176,40,166,37,47,179,46,39,78,114,118],"class_list":["post-4160","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-html","tag-html5","tag-ios-sdk","tag-iphone","tag-iphone-","tag-javascript-2","tag-jquery","tag-js","tag-39","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4160"}],"version-history":[{"count":3,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4160\/revisions"}],"predecessor-version":[{"id":4166,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/4160\/revisions\/4166"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}