{"id":11850,"date":"2022-03-24T10:00:00","date_gmt":"2022-03-24T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11850"},"modified":"2022-03-24T11:19:37","modified_gmt":"2022-03-24T02:19:37","slug":"nodejs%e3%81%ae%e5%a7%8b%e3%82%81%e6%96%b9","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11850","title":{"rendered":"Nodejs\u306e\u59cb\u3081\u65b9"},"content":{"rendered":"\n<p>NodeJS\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u767a\u3059\u308b\u305f\u3081\u306e\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u3067\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306a\u5b9f\u884c\u74b0\u5883\u3067\u3059\u3002\u4eca\u56de\u306f\u3001NodeJS\u3092Node Package Module\uff08NPM\uff09\u3092\u4f7f\u3063\u3066\u3001\u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6\u30c3\u30d7\u3067\u57fa\u672c\u7684\u306a\u5b9f\u88c5\u3068\u89e3\u8aac\u3092\u5b66\u3073\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>NodeJS\u306f\u3001\u30a4\u30d9\u30f3\u30c8\u99c6\u52d5\u578b\u306e\u30ce\u30f3\u30d6\u30ed\u30c3\u30ad\u30f3\u30b0I\/O\u30e2\u30c7\u30eb\u3092\u63a1\u7528\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u8efd\u91cf\u3067\u52b9\u7387\u7684\u3067\u3059\u3002<\/p>\n\n\n\n<p>NodeJS\u3068NPM\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3001NodeJS\u306e\u516c\u5f0f\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304b\u3089\u5165\u624b\u3067\u304d\u308b\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u7c21\u5358\u306b\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3>Nodejs<\/h3>\n\n\n\n<ul><li>NodeJS WebSite\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/li><li>\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li><li>\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306e\u624b\u9806\u306b\u5f93\u3063\u3066\u3001\u4f7f\u7528\u8a31\u8afe\u5951\u7d04\u306b\u540c\u610f\u3057\u3001\u300c\u6b21\u3078\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/li><li>\u30b7\u30b9\u30c6\u30e0\/\u30de\u30b7\u30f3\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/li><\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001nodejs\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node --version<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u3067npm\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm --version<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>test.js \u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*test.js file*\/\nconsole.log(\"Node is working\");<\/code><\/pre>\n\n\n\n<p>test.js\u306f\u3001\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089Node\u30b3\u30de\u30f3\u30c9 &gt; node test.js\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u7d42\u4e86\u3067\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3>Node Package Module<\/h3>\n\n\n\n<p>NPM\u306f\u3001JavaScript\u958b\u767a\u8005\u304c\u52b9\u7387\u7684\u306b\u4f9d\u5b58\u95a2\u4fc2\u3092\u30ed\u30fc\u30c9\u3059\u308b\u306e\u3092\u52a9\u3051\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002\u4f9d\u5b58\u95a2\u4fc2\u3092\u30ed\u30fc\u30c9\u3059\u308b\u306b\u306f\u3001\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install<\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308bpackage.json\u3068\u3044\u3046\u540d\u524d\u306ejson\u30d5\u30a1\u30a4\u30eb\u3092\u898b\u3064\u3051\u3066\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u3059\u3079\u3066\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3>Package.json<\/h3>\n\n\n\n<p>Package.json\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"name\": \"ApplicationName\",\n  \"version\": \"0.0.1\",\n  \"description\": \"Application Description\",\n  \"main\": \"server.js\",\n  \"scripts\": {\n    \"start\": \"node server.js\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https:\/\/github.com\/npm\/npm.git\"\n  },\n  \"dependencies\": {\n    \"express\": \"~3.0.1\",\n    \"angular\": \"latest\",\n    \"angular-ui-router\": \"~0.2.11\",\n  }\n}<\/code><\/pre>\n\n\n\n<p>package.json\u3067\u6700\u3082\u91cd\u8981\u306a\u306e\u306f\u3001\u540d\u524d\u3068\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002\u3053\u308c\u3089\u306f\u5b9f\u969b\u306b\u5fc5\u9808\u3067\u3042\u308a\u3001\u3053\u308c\u304c\u306a\u3044\u3068\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3>Repository<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https:\/\/github.com\/npm\/npm.git\"\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u5834\u6240\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3082\u3057git\u30ea\u30dd\u30b8\u30c8\u30ea\u304cGitHub\u3067\u306a\u3044\u5834\u5408\u306f\u3001npm docs\u30b3\u30de\u30f3\u30c9\u3067\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3>Scripts<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n \"scripts\": {\n    \"start\": \"node server.js\"\n  }\n}<\/code><\/pre>\n\n\n\n<p>NPM\u306f\u3001npm install\u3001npm start\u3001npm stop\u306a\u3069\u3001\u4fbf\u5229\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u591a\u6570\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30eb\u30fc\u30c8\u306bserver.js\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u5834\u5408\u3001npm\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067node server.js\u3092\u958b\u59cb\u30b3\u30de\u30f3\u30c9\u3068\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3>Dependencies<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n   \"dependencies\": {\n     \"express\": \"~3.0.1\",\n     \"angular\":\"latest\",\n     \"angular-ui-router\": \"~0.2.11\",\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u4f9d\u5b58\u95a2\u4fc2\u306f\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3068\u30d0\u30fc\u30b8\u30e7\u30f3\u7bc4\u56f2\u3092\u5bfe\u5fdc\u3055\u305b\u305f\u30b7\u30f3\u30d7\u30eb\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*server.js*\/\n\nconst http = require('http');\n\nconst hostname = '127.0.0.1';\nconst port = 3000;\n\nconst server = http.createServer(function(req, res) {\n  res.statusCode = 200;\n  res.setHeader('Content-Type', 'text\/plain');\n  res.end('Hello World\\n');\n});\n\nserver.listen(port, hostname, function() {\n  console.log('Server running at http:\/\/'+ hostname + ':' + port + '\/');\n});<\/code><\/pre>\n\n\n\n<p>require(&#8216;http&#8217;) \u3092\u4f7f\u3063\u3066 http \u30b5\u30fc\u30d0\u3092\u4f5c\u6210\u3057\u3001\u305d\u308c\u3092 http \u3068\u3044\u3046\u5909\u6570\u306b\u6e21\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001localHost\uff08127.0.0.1\uff09\u3068\u30dd\u30fc\u30c8\u756a\u53f73000\u3092\u4f7f\u7528\u3057\u3001\u3053\u308c\u3092\u305d\u308c\u305e\u308c\u5909\u6570hostname\u3068port\u306b\u4ee3\u5165\u3057\u3066\u3044\u307e\u3059\u3002createServer\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001http\u30b5\u30fc\u30d0\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u306b\u3001server.js\u30d5\u30a1\u30a4\u30eb\u3092node\u3067\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3063\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node server<\/code><\/pre>\n\n\n\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u958b\u304d\u3001URL http:\/\/127.0.0.1:3000\/ \u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30d6\u30e9\u30a6\u30b6\u304c\u753b\u9762\u306bHello World\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u3053\u308c\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u306enodejs\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u3001\u6b63\u5e38\u306b\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>By Tsuki<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11850\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11850\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Nodejs\u306e\u59cb\u3081\u65b9\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11850\" data-text=\"Nodejs\u306e\u59cb\u3081\u65b9\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11850\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11850\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>NodeJS\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u767a\u3059\u308b\u305f\u3081\u306e\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u3067\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306a\u5b9f\u884c\u74b0\u5883\u3067\u3059\u3002\u4eca\u56de\u306f\u3001NodeJS\u3092Node Package Module\uff08NPM\uff09\u3092\u4f7f\u3063\u3066\u3001\u30b9\u30c6\u30c3\u30d7\u30d0\u30a4\u30b9\u30c6 [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[35],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11850"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=11850"}],"version-history":[{"count":2,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11850\/revisions"}],"predecessor-version":[{"id":11855,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11850\/revisions\/11855"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}