{"id":401,"date":"2019-05-21T10:32:08","date_gmt":"2019-05-21T01:32:08","guid":{"rendered":"http:\/\/localhost:8000\/?p=401"},"modified":"2021-01-23T10:34:38","modified_gmt":"2021-01-23T01:34:38","slug":"node-npm","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2019\/05\/node-npm.html","title":{"rendered":"node.js\u304a\u3088\u3073npm\u306eTips"},"content":{"rendered":"
npm\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u8abf\u3079\u3066\u4f7f\u3044\u65b9\u3092\u307e\u3068\u3081\u305f\u3002\u4eca\u5f8c\u3082Tips\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304f\u3002<\/p>\n
brew install nodebrew<\/code><\/pre>\nNode.js\u304a\u3088\u3073npm\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n# \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u4e00\u89a7\u3092\u53d6\u5f97\nnodebrew ls-remote\n\n# install-binary\u3092\u914d\u7f6e\u3059\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\nmkdir ~\/.nodebrew\/src\n\n# \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnodebrew install-binary v12.2.0\nnodebrew install-binary latest # \u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\n\n# \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u4e00\u89a7\u8868\u793a\nnodebrew ls\n\n# \u7279\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306enode\u3092\u6709\u52b9\u5316\u3059\u308b\n nodebrew use v12.2.0\n\n# node\u30b3\u30de\u30f3\u30c9\u306bPATH\u3092\u901a\u3059\nvi ~\/.bash_profile\n+ export PATH=$PATH:~\/.nodebrew\/current\/bin\nsource ~\/.bash_profile\n\n# Node.js\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d\nnode -v\n\n# npm\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d\nnpm -v<\/code><\/pre>\nnpm\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n
npm\u306fNode.js\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u3067\u3042\u308b\u3002<\/p>\n
\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n# \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm install \u30d1\u30c3\u30b1\u30fc\u30b8\u540d1 \u30d1\u30c3\u30b1\u30fc\u30b8\u540d2 \u30d1\u30c3\u30b1\u30fc\u30b8\u540d3@1.2.3\n# \u30b0\u30ed\u30fc\u30d0\u30eb\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm install -g \u30d1\u30c3\u30b1\u30fc\u30b8\u540d1 \u30d1\u30c3\u30b1\u30fc\u30b8\u540d2 \u30d1\u30c3\u30b1\u30fc\u30b8\u540d3@1.2.3<\/code><\/pre>\n\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n# \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304b\u3089\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm uninstall \u30d1\u30c3\u30b1\u30fc\u30b8\u540d\n# \u30b0\u30ed\u30fc\u30d0\u30eb\u304b\u3089\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm uninstall \u30d1\u30c3\u30b1\u30fc\u30b8\u540d<\/code><\/pre>\n\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u30d1\u30c3\u30b1\u30fc\u30b8\u4e00\u89a7<\/h3>\nnpm ls<\/code><\/pre>\nnpm-root\uff08node_modules\u306e\u30d5\u30a9\u30eb\u30c0\uff09\u306e\u8a2d\u5b9a<\/h3>\n# node_modules\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u78ba\u8a8d\nnpm root\nnpm root -g\n# node modules\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u5909\u66f4\n# .npmrc\u3067\u3082\u5909\u66f4\u3067\u304d\u308b\u6a21\u69d8\nnpm config set prefix node_modules\u306e\u30d1\u30b9\nnpm config set -g prefix node_modules\u306e\u30d1\u30b9<\/code><\/pre>\npackage.json\u306b\u3088\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406<\/h2>\n
package.json\u306e\u5b9a\u7fa9\u306b\u5f93\u3063\u3066\u307e\u3068\u3081\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n
\u73fe\u5728install\u3055\u308c\u3066\u3044\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5143\u306b\u3001package.json\u3092\u4f5c\u6210\u3059\u308b<\/h3>\nnpm init<\/code><\/pre>\npackage.json\u306e\u30b5\u30f3\u30d7\u30eb<\/p>\n
{\n "name": "vue-sample",\n "version": "0.1.0",\n "private": true,\n "dependencies": {\n "core-js": "^2.6.5",\n "vue": "^2.6.10",\n (\u7701\u7565)\n },\n "devDependencies": {\n "@vue\/cli-plugin-babel": "^3.7.0",\n "@vue\/cli-plugin-eslint": "^3.7.0",\n (\u7701\u7565)\n }\n}<\/code><\/pre>\ndependencies<\/code>\u3068devDependencies<\/code>\u306e\u4e8c\u7a2e\u985e\u3042\u308b\u3002<\/p>\n\ndependencies<\/code>\u306f\u672c\u756a\u7528\u3002\u672c\u756a\u74b0\u5883\u3068\u958b\u767a\u74b0\u5883\u306e\u4e21\u65b9\u3067\u9069\u7528\u3055\u308c\u308b<\/li>\ndevDependencies<\/code>\u306f\u958b\u767a\u7528\u3002\u672c\u756a\u74b0\u5883\u3067\u306f\u9069\u7528\u3055\u308c\u306a\u3044<\/li>\n<\/ul>\npackage.json\u306e\u5b9a\u7fa9\u306b\u5f93\u3063\u3066\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h3>\n
--production<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u6709\u7121\u3067\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5bfe\u8c61\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u7570\u306a\u308b\u3053\u3068\u306b\u6ce8\u610f\u3002<\/p>\n# \u5168\u90e8\uff08\u3064\u307e\u308adependencies+devDependencies\uff09\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm install\n\n# \u672c\u756a\u7528\uff08\u3064\u307e\u308adependencies\u306e\u307f\uff09\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nnpm install --production<\/code><\/pre>\n\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\/\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001package.json\u306b\u3082\u8a18\u9332\u3059\u308b<\/h3>\n
--save<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u308b\u3068\u3001package.json\u306b\u3082\u8a18\u9332\u3055\u308c\u308b\u3002<\/p>\n# dependencies\u306b\u8a18\u9332\u3059\u308b\nnpm install --save \u30d1\u30c3\u30b1\u30fc\u30b8\u540d\nnpm uinstall --save \u30d1\u30c3\u30b1\u30fc\u30b8\u540d\n\n# devDependencies\u306b\u8a18\u9332\u3059\u308b\nnpm install --save-dev \u30d1\u30c3\u30b1\u30fc\u30b8\u540d\nnpm uninstall --save-dev \u30d1\u30c3\u30b1\u30fc\u30b8\u540d<\/code><\/pre>\npackage.json\u306b\u3088\u308b\u30bf\u30b9\u30af\u7ba1\u7406<\/h2>\n
npm\u306f\u30bf\u30b9\u30af\u30e9\u30f3\u30ca\u30fc\u3068\u3057\u3066\u3082\u4f7f\u3048\u308b\u3002\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u3067\u308f\u304b\u308a\u3084\u3059\u3044\u3002<\/p>\n
package.json\u306escripts<\/code>\u306b\u30bf\u30b9\u30af\u3092\u5b9a\u7fa9\u3059\u308b<\/h3>\n\u8abf\u3079\u305f\u306e\u3060\u304c\u3001script\u3092\u8907\u6570\u884c\u5b9f\u884c\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u6a21\u69d8\u3002
\n\u3068\u308a\u3042\u3048\u305a\u8907\u6570\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f&&<\/code>\u3067\u7e4b\u3044\u3067\u5b9f\u884c\u3059\u308b\u3002<\/p>\n{\n "name": "vue-sample",\n (\u7701\u7565)\n "scripts": {\n "serve": "vue-cli-service serve",\n "build": "vue-cli-service build",\n "lint": "vue-cli-service lint",\n "sample": "pwd && ls -la"\n },\n (\u7701\u7565)\n}<\/code><\/pre>\n\u5b9a\u7fa9\u3055\u308c\u305f\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3059\u308b<\/h3>\n
npm run \u30bf\u30b9\u30af\u540d<\/code>\u3067\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\nnpm run serve\nnpm run build\nnpm run lint\nnpm run sample<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"npm\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u8abf\u3079\u3066\u4f7f\u3044\u65b9\u3092\u307e\u3068\u3081\u305f\u3002\u4eca\u5f8c\u3082Tips\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304f\u3002 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5 nodebrew\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb brew install nodebrew Node.js\u304a\u3088\u3073npm\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb # \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u4e00\u89a7\u3092\u53d6\u5f97 nodebrew ls-remote # install-binary\u3092\u914d\u7f6e\u3059\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210 mkdir ~\/.nodebrew\/src # \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb nodebrew install-binary v12.2.0 nodebrew install-binary latest # \u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3 # \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u4e00\u89a7\u8868\u793a nodebrew ls # \u7279\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306enode\u3092\u6709\u52b9\u5316\u3059\u308b nodebrew use v12.2.0 # node\u30b3\u30de\u30f3\u30c9\u306bPATH\u3092\u901a\u3059 vi ~\/.bash_prof <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/401"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=401"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":403,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/401\/revisions\/403"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}