{"id":653,"date":"2018-03-05T10:55:19","date_gmt":"2018-03-05T02:55:19","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=653"},"modified":"2018-03-05T10:55:19","modified_gmt":"2018-03-05T02:55:19","slug":"%e4%bd%bf%e7%94%a8sinopia%e6%90%ad%e5%bb%ba%e7%a7%81%e6%9c%89%e7%9a%84npm%e4%bb%93%e5%ba%93","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=653","title":{"rendered":"\u4f7f\u7528Sinopia\u642d\u5efa\u79c1\u6709\u7684npm\u4ed3\u5e93"},"content":{"rendered":"<h3>\u9700\u6c42<\/h3>\n<p>\u516c\u53f8\u51fa\u4e8e\u81ea\u8eab\u9690\u79c1\u4fdd\u62a4\u9700\u8981,\u4e0d\u60f3\u628a\u81ea\u5df1\u7684\u4ee3\u7801\u5f00\u6e90\u5230\u5305\u7ba1\u7406\u533a\uff0c\u4f46\u662f\u53c8\u6025\u9700\u4e00\u5957\u5b8c\u6574\u5305\u7ba1\u5de5\u5177\uff0c\u6765\u7ba1\u7406\u8d8a\u6765\u8d8a\u591a\u7684\u7ec4\u4ef6\u3001\u6a21\u5757\u548c\u9879\u76ee\u3002\u5bf9\u4e8e\u524d\u7aef\uff0c\u6700\u719f\u6089\u7684\u83ab\u8fc7\u4e8enpm\uff0cbower\u7b49\uff1b\u4f46\u662fbower\u7684\u5e02\u573a\u517c\u5bb9\u6027\u660e\u663e\u6ca1\u6709npm\u5f3a\u58ee\uff0c\u52a0\u4e4bcommonjs\u89c4\u8303\u7684\u65e5\u76ca\u6210\u719f\u3002npm\u5e94\u8be5\u662f\u524d\u7aef\u5305\u7ba1\u7406\u7684\u4e0d\u4e8c\u9009\u62e9\u3002<\/p>\n<p>\u516c\u53f8\u5bf9\u4e8e\u642d\u5efa\u672c\u5730\u79c1\u6709npm\u5e93\u6709\u5982\u4e0b\u8981\u6c42\uff1a<\/p>\n<ol>\n<li>\u79c1\u6709\u5305\u6258\u7ba1\u5728\u5185\u90e8\u670d\u52a1\u5668\u4e2d<\/li>\n<li>\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86\u516c\u5171\u4ed3\u5e93\u4e0a\u7684\u516c\u5171\u5305\uff0c\u4e5f\u4f7f\u7528\u4e86\u5185\u90e8\u670d\u52a1\u5668\u4e0a\u7684\u79c1\u6709\u5305<\/li>\n<li>\u5e0c\u671b\u4e0b\u8f7d\u7684\u65f6\u5019\uff0c\u516c\u5171\u5305\u8d70\u516c\u5171\u4ed3\u5e93\uff0c\u79c1\u6709\u5305\u8d70\u5185\u90e8\u670d\u52a1\u5668\u7684\u79c1\u6709\u4ed3\u5e93<\/li>\n<li>\u670d\u52a1\u5668\u786c\u76d8\u6709\u9650\uff0c\u5e0c\u671b\u53ea\u7f13\u5b58\u4e0b\u8f7d\u8fc7\u7684\u5305\uff0c\u800c\u4e0d\u662f\u5168\u90e8\u540c\u6b65\u3002<\/li>\n<li>\u5bf9\u4e8e\u4e0b\u8f7d\uff0c\u53d1\u5e03npm\u5305\u6709\u5bf9\u5e94\u7684\u6743\u9650\u7ba1\u7406\uff0c\u5b89\u88c5\u65b9\u4fbf\uff0c\u914d\u7f6e\u7b80\u5355\uff0c\u4f9d\u8d56\u5c11\u3002<\/li>\n<\/ol>\n<h3>\u5173\u4e8esinopia\uff1f<\/h3>\n<p><a href=\"https:\/\/github.com\/rlidwka\/sinopia\">Sinopia<\/a>\u00a0\u662f\u4e00\u4e2a\u96f6\u914d\u7f6e\u7684\u79c1\u6709\u7684\u5e26\u7f13\u5b58\u529f\u80fd\u7684npm\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4f5c\u8005\u662f\u662f<a href=\"https:\/\/github.com\/rlidwka\">rlidwka<\/a>\uff0c\u4e00\u4e2a\u5927\u795e\uff0c\u4e5f\u662f\u4e00\u53ea\u732b\uff5e \u5f80\u793e\u533a\u5185\u8d21\u732e\u8fc7\u5f88\u591a\u4ee3\u7801\uff0c\u5305\u62ec jshttp, markdown-it \u7b49\u7b49\uff0c\u4e5f\u662f Node.js \u6838\u5fc3\u4ee3\u7801\u5e93\u7684\u6d3b\u8dc3\u8d21\u732e\u8005\u3002<\/p>\n<p>\u4f7f\u7528sinopia\uff0c\u4f60\u4e0d\u7528\u5b89\u88c5CouchDB\u6216MYSQL\u4e4b\u7c7b\u7684\u6570\u636e\u5e93\uff0cSinopia\u6709\u81ea\u5df1\u7684\u8ff7\u4f60\u6570\u636e\u5e93\uff0c\u5982\u679c\u8981\u4e0b\u8f7d\u7684\u5305\u4e0d\u5b58\u5728\uff0c\u5b83\u5c06\u81ea\u52a8\u53bb\u4f60\u914d\u7f6e\u7684npm\u5730\u5740\u4e0a\u53bb\u4e0b\u8f7d\uff0c\u800c\u4e14\u786c\u76d8\u4e2d\u53ea\u7f13\u5b58\u4f60\u73b0\u5728\u8fc7\u7684\u5305\uff0c\u4ee5\u8282\u7701\u7a7a\u95f4\u3002<\/p>\n<h4>\u4e3a\u4ec0\u4e48\u9009\u62e9sinopia<\/h4>\n<p>sinopia\u6709\u4ee5\u4e0b\u51e0\u4e2a\u4f18\u52bf\u503c\u5f97\u5173\u6ce8\uff1a<\/p>\n<ol>\n<li>\u4e0d\u540c\u6b65\u62c9\u53d6npm\u5e93\uff0c\u5360\u636e\u5927\u91cf\u786c\u76d8\uff0c\u6ca1\u6709\u786c\u76d8\u88ab\u6491\u7206\u7684\u95ee\u9898\uff1b<\/li>\n<li>\u5b89\u88c5\u914d\u7f6e\u6781\u5176\u7b80\u5355,\u4e0d\u9700\u8981\u6570\u636e\u5e93\uff1b<\/li>\n<li>\u652f\u6301\u914d\u7f6e\u4e0a\u6e38registry\u914d\u7f6e\uff0c\u4e00\u6b21\u62c9\u53d6\u5373\u7f13\u5b58\uff1b<\/li>\n<li>\u652f\u6301forever\u53capm2\u5b88\u62a4\u8fdb\u7a0b\u7ba1\u7406\uff1b<\/li>\n<\/ol>\n<h4>\u5176\u4ed6\u65b9\u6cd5<\/h4>\n<ul>\n<li>\u4f7f\u7528 git+ssh \u8fd9\u79cd\u65b9\u5f0f\u76f4\u63a5\u5f15\u7528\u5230 GitHub \u9879\u76ee\u5730\u5740<\/li>\n<\/ul>\n<p>\u55ef\uff0c\u8fd9\u79cd\u65b9\u5f0f\u53ef\u884c\uff0c\u4e5f\u6700\u7b80\u5355\uff0c\u4f46\u771f\u771f\u7684\u592a\u70c2\u4e86\uff0c\u59d1\u4e14\u4e0d\u8bf4\u4e0d\u80fd\u4f7f\u7528 semver\uff0c\u5173\u952e\u8fd8\u662f url \u592a\u4e11\uff0c\u5982\u679c\u662f\u5f3a\u8feb\u75c7\u771f\u7684\u6ca1\u6cd5\u5fcd\uff5e<\/p>\n<ul>\n<li>\u4f7f\u7528cnpm<\/li>\n<\/ul>\n<p>\u6682\u4e14\u4e0d\u8bba cnpm \u53ea\u662f\u4f5c\u4e3a\u955c\u50cf\u4f7f\u7528\uff0c\u5176\u5b9e\u8fd9\u4e2a\u65b9\u6848\u7f3a\u70b9\u5c31\u633a\u591a\u7684\uff0c\u7528\u7684\u4eba\u591a\uff0c\u901f\u5ea6\u4e0d\u4e00\u5b9a\u5feb\uff0c\u7f13\u5b58\uff0c\u5173\u952e\u662f\u4e0d\u652f\u6301\u53d1\u5e03\u5305\u4ee5\u53ca\u767b\u9646\u3001\u6ce8\u518c\uff0c\u518d\u52a0\u4e0a\u914d\u7f6e\u8fc7\u4e8e\u590d\u6742\u3002\u800c\u4e14\uff0c\u8fd8\u9700\u8981\u5b89\u88c5\u6570\u636e\u5e93\u3002<\/p>\n<ul>\n<li>npm on-site<\/li>\n<\/ul>\n<p>\u571f\u8c6a\u554a\uff0c\u6211\u8fd8\u80fd\u8bf4\u4ec0\u4e48\u5462\u3002\u3002\u3002\u4f46\u662f\u95ee\u9898\u662f\uff0cnpm\u5728\u56fd\u5185\u8bbf\u95ee\u6162\uff0c\u8fd8\u662f\u4e0d\u662f\u7684\u65e0\u6cd5\u8bbf\u95ee\uff0c\u82b1\u94b1\u4e5f\u4e70\u4e0d\u5230\u597d\u7684\u670d\u52a1\uff0c\u4f55\u5fc5\u5462\u3002<\/p>\n<h3>\u90e8\u7f72<\/h3>\n<h4>\u5b89\u88c5<\/h4>\n<p>\u9996\u5148\uff0c\u4f60\u8981\u81ea\u5df1\u914d\u7f6enodejs\u53canpm\u7684\u73af\u5883\uff0c\u7136\u540e\u8fd0\u884c<\/p>\n<pre><code>npm install -g sinopia\n<\/code><\/pre>\n<h4>\u542f\u52a8<\/h4>\n<pre><code>$ sinopia\n warn  --- config file  - .....\\AppData\\Roaming\\sinopia\\config.yaml\n warn  --- http address - http:\/\/localhost:4873\/\n<\/code><\/pre>\n<p>\u7136\u540e\u6253\u5f00\uff1a<code>http:\/\/localhost:4873\/<\/code><br \/>\n<a href=\"https:\/\/cloud.githubusercontent.com\/assets\/9441951\/20638271\/2dc7e16e-b3dd-11e6-951b-97d22d0009f8.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/cloud.githubusercontent.com\/assets\/9441951\/20638271\/2dc7e16e-b3dd-11e6-951b-97d22d0009f8.png\" alt=\"image\" \/><\/a><\/p>\n<p>\u5982\u679c\u80fd\u6b63\u5e38\u663e\u793a\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<h4>\u4f7f\u7528pm2\u542f\u52a8<\/h4>\n<p>\u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528<a href=\"https:\/\/github.com\/Unitech\/pm2\">pm2<\/a>\u6216\u5176\u4ed6\u7684\u5b88\u62a4\u8fdb\u7a0b\u8fdb\u884c\u7ba1\u7406\uff0c\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>\u5b89\u88c5pm2:<code>npm install -g pm2<\/code><\/p>\n<p>\u542f\u52a8\uff1apm2 start `which sinopia`<\/p>\n<p>\u66f4\u591a\u9ad8\u7ea7\u7684pm2\u4f7f\u7528\u65b9\u6cd5\u53ef\u4ee5\u67e5\u770b<a href=\"https:\/\/wohugb.gitbooks.io\/pm2\/content\/\" rel=\"nofollow\">pm2\u7535\u5b50\u4e66<\/a>\uff0c\u76f8\u5f53\u8be6\u7ec6\uff0c\u5f3a\u70c8\u63a8\u8350\u3002<\/p>\n<h3>\u670d\u52a1\u7aef\u914d\u7f6e<\/h3>\n<p>Sinopia\u7684\u7279\u70b9\u662f\uff0c\u4f60\u5728\u54ea\u4e2a\u76ee\u5f55\u8fd0\u884c\uff0c\u5b83\u7684\u5c31\u4f1a\u5728\u5bf9\u5e94\u7684\u76ee\u5f55\u4e0b\u521b\u5efa\u81ea\u5df1\u7684\u6587\u4ef6\u3002\u76ee\u5f55\u4e0b\u9ed8\u8ba4\u6709\u4e24\u4e2a\u6587\u4ef6\uff1a<code>config.yaml<\/code>\u548c<code>storage<\/code>\uff0c<code>htpasswd<\/code>\u662f\u6dfb\u52a0\u7528\u6237\u4e4b\u540e\u81ea\u52a8\u521b\u5efa\u7684\u3002<\/p>\n<pre><code>root@debian:\/usr\/local\/apps\/sinopia# ls\nconfig.yaml  htpasswd  storage\n<\/code><\/pre>\n<p>\u5176\u4e2dconfig.yaml\u662f\u7528\u6765\u914d\u7f6e\u8bbf\u95ee\u6743\u9650\uff0c\u4ee3\u7406\uff0c\u6587\u4ef6\u5b58\u50a8\u8def\u5f84\u7b49\u6240\u6709\u914d\u7f6e\u4fe1\u606f\u7684\uff0chtpasswd\u7528\u6765\u4fdd\u5b58\u7528\u6237\u7684\u8d26\u53f7\u5bc6\u7801\u7b49\u606f\u606f\uff0cstorage\u662f\u7528\u6765\u5b58\u653enpm\u5305\u7684\u3002<\/p>\n<h4>config.yaml\u914d\u7f6e\u6587\u4ef6<\/h4>\n<pre><code>#\n# This is the default config file. It allows all users to do anything,\n# so don't use it on production systems.\n#\n# Look here for more config file examples:\n# https:\/\/github.com\/rlidwka\/sinopia\/tree\/master\/conf\n#\n\n# path to a directory with all packages\nstorage: .\/storage  \/\/npm\u5305\u5b58\u653e\u7684\u8def\u5f84\n\nauth:\n  htpasswd:\n    file: .\/htpasswd   \/\/\u4fdd\u5b58\u7528\u6237\u7684\u8d26\u53f7\u5bc6\u7801\u7b49\u4fe1\u606f\n    # Maximum amount of users allowed to register, defaults to \"+inf\".\n    # You can set this to -1 to disable registration.\n    max_users: -1  \/\/\u9ed8\u8ba4\u4e3a1000\uff0c\u6539\u4e3a-1\uff0c\u7981\u6b62\u6ce8\u518c\n\n# a list of other known repositories we can talk to\nuplinks:\n  npmjs:\n    url: http:\/\/registry.npm.taobao.org\/  \/\/\u9ed8\u8ba4\u4e3anpm\u7684\u5b98\u7f51\uff0c\u7531\u4e8e\u56fd\u60c5\uff0c\u4fee\u6539 url \u8ba9sinopia\u4f7f\u7528 \u6dd8\u5b9d\u7684npm\u955c\u50cf\u5730\u5740\n\npackages:  \/\/\u914d\u7f6e\u6743\u9650\u7ba1\u7406\n  '@*\/*':\n    # scoped packages\n    access: $all\n    publish: $authenticated\n\n  '*':\n    # allow all users (including non-authenticated users) to read and\n    # publish all packages\n    #\n    # you can specify usernames\/groupnames (depending on your auth plugin)\n    # and three keywords: \"$all\", \"$anonymous\", \"$authenticated\"\n    access: $all\n\n    # allow all known users to publish packages\n    # (anyone can register by default, remember?)\n    publish: $authenticated\n\n    # if package is not available locally, proxy requests to 'npmjs' registry\n    proxy: npmjs\n\n# log settings\nlogs:\n  - {type: stdout, format: pretty, level: http}\n  #- {type: file, path: sinopia.log, level: info}\n\n# you can specify listen address (or simply a port)\nlisten: 0.0.0.0:4873  \/\/\/\/\u9ed8\u8ba4\u6ca1\u6709\uff0c\u53ea\u80fd\u5728\u672c\u673a\u8bbf\u95ee\uff0c\u6dfb\u52a0\u540e\u53ef\u4ee5\u901a\u8fc7\u5916\u7f51\u8bbf\u95ee\u3002\n<\/code><\/pre>\n<h4>\u90e8\u5206\u914d\u7f6e\u5b57\u6bb5\u610f\u4e49<\/h4>\n<p>storage: \u4ed3\u5e93\u4fdd\u5b58\u7684\u8def\u5f84<\/p>\n<p>web: \u662f\u5426\u652f\u6301WEB\u63a5\u53e3<\/p>\n<p>auth: \u9a8c\u8bc1\u76f8\u5173<\/p>\n<p>uplinks: \u914d\u7f6e\u4e0a\u6e38\u7684npm\u670d\u52a1\u5668\uff0c\u4e3b\u8981\u662f\u7528\u4e8e\u8bf7\u6c42\u7684\u4ed3\u5e93\u4e0d\u5b58\u5728\u65f6\u53bb\u4e0a\u6e38\u670d\u52a1\u5668\u62c9\u53d6<\/p>\n<p>packages: \u914d\u7f6e\u6a21\u5757\/\u5305\u7684\u53d1\u5e03(publish)\u3001\u4e0b\u8f7d(access)\u7684\u6743\u9650\u7b49<\/p>\n<p>listen: \u914d\u7f6e\u76d1\u542c\u7aef\u53e3\u4e0e\u4e3b\u673a\u540d<\/p>\n<h4>auth\u914d\u7f6e<\/h4>\n<p><code>max_users: -1<\/code>\u8868\u793a\u6211\u4eec\u5c06\u6700\u5927\u7528\u6237\u6570\u8bbe\u7f6e\u4e3a\uff0d1\uff0c\u8868\u793a\u7981\u7528 npm adduser \u547d\u4ee4\u6765\u521b\u5efa\u7528\u6237\uff0c\u4e0d\u8fc7\u6211\u4eec\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u5f53\u524d\u76ee\u5f55\u4e0b\u7684 htpasswd \u6587\u4ef6\u6765\u521d\u59cb\u5316\u7528\u6237\u3002<br \/>\n\u793a\u4f8b\uff1a<\/p>\n<pre><code>\nyorkie:{SHA}?????????????????=:autocreated 2016-02-05T15:33:46.238Z\n\nweflex:{SHA}????????????????=:autocreated 2016-02-05T15:39:19.960Z\n\njames:{SHA}????????????????=:autocreated 2016-02-05T17:59:05.041Z\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u52a0\u5bc6\u7b97\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u7b80\u5355\u7684SHA1\u54c8\u7a00\u4e4b\u540e\u518d\u8f6c\u6362\u6210 Base64 \u8f93\u51fa\u5c31\u597d\uff0c\u540e\u9762\u8ddf\u7740\u7684\u53ea\u662f\u8868\u793a\u65f6\u95f4\u3002<\/p>\n<h4>packages\u914d\u7f6e<\/h4>\n<p>\u914d\u7f6e\u5927\u81f4\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff0c\u4e00\u4e2a\u662f\u4ee5 @weflex\/* \u4e3a\u5f00\u5934\u7684\uff0c\u53e6\u4e00\u4e2a\u5219\u662f\u901a\u914d\u7b26 *\u3002<\/p>\n<p>\u8fd9\u4e2a\u5f53\u7136\u5c31\u662f\u5bf9 package.json \u4e2d\u7684 name \u5b57\u6bb5\u8fdb\u884c\u5339\u914d\uff0c\u6bd4\u5982\u00a0\u5c06\u5339\u914d\u7b2c\u4e00\u4e2a\u914d\u7f6e\uff0c\u800c express \u5219\u5339\u914d\u7b2c\u4e8c\u4e2a\u3002<\/p>\n<p>\u8fd9\u91cc\u8fd9\u4e48\u914d\u7f6e\u7684\u610f\u4e49\u5728\u4e8e\uff1a\u4e00\u822c\u56e2\u961f\u6216\u8005\u516c\u53f8\u7684\u79c1\u6709\u9879\u76ee\uff0c\u4f1a\u91c7\u7528\u4e0d\u540c\u7684\u6743\u9650\u63a7\u5236\uff0c\u4e8e\u662f\u8fd9\u91cc\u501f\u7528\u4e86 NPM \u7684 scoped name \u5373\u00a0<a class=\"user-mention\" href=\"https:\/\/github.com\/company\">@Company<\/a>\u00a0\u7684\u5f62\u5f0f\uff0c\u4f8b\u5982\u00a0\u5373\u8868\u793a WeFlex \u4e0b\u5c5e\u7684 app \u9879\u76ee\u4e86\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6bcf\u4e00\u4e2a\u547d\u540d\u8fc7\u6ee4\u5668(filter)\u4e0b\u90fd\u6709\u4e09\u9879\u57fa\u672c\u8bbe\u7f6e\uff1a<\/p>\n<ul>\n<li>access: \u8868\u793a\u54ea\u4e00\u7c7b\u7528\u6237\u53ef\u4ee5\u5bf9\u5339\u914d\u7684\u9879\u76ee\u8fdb\u884c\u5b89\u88c5(install)<\/li>\n<li>publish: \u8868\u793a\u54ea\u4e00\u7c7b\u7528\u6237\u53ef\u4ee5\u5bf9\u5339\u914d\u7684\u9879\u76ee\u8fdb\u884c\u53d1\u5e03(publish)<\/li>\n<li>proxy: \u5982\u5176\u540d\uff0c\u8fd9\u91cc\u7684\u503c\u662f\u5bf9\u5e94\u4e8e uplinks \u7684<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e1\u548c2\u7684\u503c\uff0c\u6211\u4eec\u901a\u5e38\u6709\u4ee5\u4e0b\u4e00\u4e9b\u53ef\u9009\u7684\u914d\u7f6e\uff1a<\/p>\n<ul>\n<li>$all \u8868\u793a\u6240\u6709\u4eba\u90fd\u53ef\u4ee5\u6267\u884c\u5bf9\u5e94\u7684\u64cd\u4f5c<\/li>\n<li>$authenticated \u8868\u793a\u53ea\u6709\u901a\u8fc7\u9a8c\u8bc1\u7684\u4eba\u53ef\u4ee5\u6267\u884c\u5bf9\u5e94\u64cd\u4f5c<\/li>\n<li>$anonymous \u8868\u793a\u53ea\u6709\u533f\u540d\u8005\u53ef\u4ee5\u8fdb\u884c\u5bf9\u5e94\u64cd\u4f5c\uff08\u901a\u5e38\u65e0\u7528\uff09<\/li>\n<\/ul>\n<p>\u6216\u8005\u4e5f\u53ef\u4ee5\u6307\u5b9a\u5bf9\u5e94\u4e8e\u4e4b\u524d\u6211\u4eec\u914d\u7f6e\u7684\u7528\u6237\u8868 htpasswd \u4e2d\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u7528\u6237\uff0c\u8fd9\u6837\u5c31\u660e\u786e\u5730\u6307\u5b9a\u54ea\u4e9b\u7528\u6237\u53ef\u4ee5\u6267\u884c\u5339\u914d\u7684\u64cd\u4f5c<br \/>\n\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u518d\u8fd0\u884c\uff1a<\/p>\n<pre><code>$ sinopia -c config.yml\n<\/code><\/pre>\n<h3>\u5ba2\u6237\u7aef\u4f7f\u7528<\/h3>\n<blockquote><p>\u5f3a\u70c8\u63a8\u8350\u4f7f\u7528nrm\u6765\u7ba1\u7406\u81ea\u5df1\u7684\u4ee3\u7406\u3002<\/p><\/blockquote>\n<h4>\u5b89\u88c5nrm:<\/h4>\n<p>\u5168\u5c40\u5b89\u88c5nrm\u53ef\u4ee5\u5feb\u901f\u4fee\u6539,\u5207\u6362,\u589e\u52a0npm\u955c\u50cf\u5730\u5740\u3002<\/p>\n<pre><code>$ npm install -g nrm # \u5b89\u88c5nrm\n$ nrm add XXXXX http:\/\/XXXXXX:4873 # \u6dfb\u52a0\u672c\u5730\u7684npm\u955c\u50cf\u5730\u5740\n$ nrm use XXXX # \u4f7f\u7528\u672c\u5740\u7684\u955c\u50cf\u5730\u5740\n<\/code><\/pre>\n<h4>nrm\u7684\u5176\u4ed6\u547d\u4ee4\uff1a<\/h4>\n<pre><code>$ nrm --help  # \u67e5\u770bnrm\u547d\u4ee4\u5e2e\u52a9\n$ nrm list # \u5217\u51fa\u53ef\u7528\u7684 npm \u955c\u50cf\u5730\u5740\n$ nrm use taobao # \u4f7f\u7528`\u6dd8\u5b9dnpm`\u955c\u50cf\u5730\u5740\n<\/code><\/pre>\n<h4>\u5b89\u88c5\u5305<\/h4>\n<p>\u5b89\u88c5\u5b8c\u6210.\u4e4b\u540e\u4f60\u901a\u8fc7npm install \u5b89\u88c5\u7684\u5305,sinopia\u90fd\u4f1a\u5e2e\u4f60\u7f13\u5b58\u5230\u672c\u5730\u4e86.\u8bd5\u4e00\u4e0b\u5427\u3002<\/p>\n<pre><code>mkdir test &amp;&amp; cd test\nnpm install lodash # sinopia\u53d1\u73b0\u672c\u5730\u6ca1\u6709 lodash\u5305,\u5c31\u4f1a\u4ece taobao\u955c\u50cf\u4e0b\u8f7d\nrm -rf node-modules # \u5220\u9664\u76ee\u5f55\nnpm insatll lodash # \u7b2c\u4e8c\u6b21\u5b89\u88c5\u5c31\u4f1a\u4ece\u7f13\u5b58\u4e0b\u8f7d\u4e86,\u901f\u5ea6\u5f88\u5feb\n<\/code><\/pre>\n<h4>\u521b\u5efa\u7528\u6237\u4e0e\u53d1\u5e03\u5305<\/h4>\n<p>\u521b\u5efa\u65b0\u7528\u6237<\/p>\n<p>1.\u786e\u4fdd\u81ea\u5df1\u5df2\u7ecf\u5207\u6362\u5230\u914d\u7f6e\u7684\u4ee3\u7406<\/p>\n<pre><code>\u279c  ~ nrm ls\n\n  npm ---- https:\/\/registry.npmjs.org\/\n  cnpm --- http:\/\/r.cnpmjs.org\/\n  taobao - http:\/\/registry.npm.taobao.org\/\n  nj ----- https:\/\/registry.nodejitsu.com\/\n  rednpm - http:\/\/registry.mirror.cqupt.edu.cn\n  npmMirror  https:\/\/skimdb.npmjs.com\/registry\n* sinopia  http:\/\/192.168.1.200:4873\/\n<\/code><\/pre>\n<p>2.\u8fd0\u884c<code>npm adduser<\/code>,\u586b\u5199\u4fe1\u606f\uff0c\u6ce8\u518c\u8d26\u53f7\u3002\u5982\u679c\u5df2\u7ecf\u6709\u8d26\u53f7\uff0c\u76f4\u63a5\u8fd0\u884c<code>npm login<\/code>\u5373\u53ef\u3002<\/p>\n<pre><code>\u279c  ~ npm adduser\n  Username: test\n  Password:\n<\/code><\/pre>\n<p>3.\u8fd0\u884c<code>$ npm publish<\/code>\u53d1\u5e03\u65b0\u5305\u3002<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<ul>\n<li>\u5230\u6b64\u4e3a\u6b62\u5427\uff0c\u5269\u4e0b\u7684\u5751\u81ea\u5df1\u8e29\u5427\uff0c\u591a\u8e29\u5751\u624d\u80fd\u591a\u6210\u957f\u3002<\/li>\n<li>\u4fdd\u5b58\u597d\u4f60\u7684 htpasswd \u6587\u4ef6\uff0c\u4e0d\u8981\u6cc4\u6f0f\u5230\u4efb\u4f55\u516c\u6709\u4ed3\u5e93\u4e2d\u53bb\u3002<\/li>\n<li>\u4ee5\u4e0a\u7684\u60c5\u51b5\u5e76\u6ca1\u6709\u8003\u8651\u5728\u9047\u5230\u4e00\u4e9b\u9ed1\u5ba2\u653b\u51fb\u7684\u60c5\u51b5\u4e0b\uff0c\u6240\u4ee5\u4e3a\u4e86\u5c3d\u91cf\u4fdd\u8bc1\u4ee3\u7801\u7684\u5b89\u5168\uff0c\u53ef\u4ee5\u5728\u524d\u7aef\u52a0\u4e00\u5c42 Nginx \u7136\u540e\u914d\u7f6e SSH \u516c\u94a5\u6765\u4f5c\u4e3a\u53cc\u5c42\u9a8c\u8bc1\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42 \u516c\u53f8\u51fa\u4e8e\u81ea\u8eab\u9690\u79c1\u4fdd\u62a4\u9700\u8981,\u4e0d\u60f3\u628a\u81ea\u5df1\u7684\u4ee3\u7801\u5f00\u6e90\u5230\u5305\u7ba1\u7406\u533a\uff0c\u4f46\u662f\u53c8\u6025\u9700\u4e00\u5957\u5b8c\u6574\u5305\u7ba1\u5de5\u5177\uff0c\u6765\u7ba1\u7406\u8d8a\u6765\u8d8a\u591a\u7684\u7ec4\u4ef6\u3001\u6a21\u5757\u548c\u9879\u76ee\u3002\u5bf9\u4e8e\u524d\u7aef\uff0c\u6700\u719f\u6089\u7684\u83ab\u8fc7\u4e8enpm\uff0cbower\u7b49\uff1b\u4f46\u662fbower\u7684\u5e02\u573a\u517c\u5bb9\u6027\u660e\u663e\u6ca1\u6709npm\u5f3a\u58ee\uff0c\u52a0\u4e4bcommonjs\u89c4\u8303\u7684\u65e5\u76ca\u6210\u719f\u3002npm\u5e94\u8be5\u662f\u524d\u7aef\u5305\u7ba1\u7406\u7684\u4e0d\u4e8c\u9009\u62e9\u3002 \u516c\u53f8\u5bf9\u4e8e\u642d\u5efa\u672c\u5730\u79c1\u6709npm\u5e93\u6709\u5982\u4e0b\u8981\u6c42\uff1a \u79c1\u6709\u5305\u6258\u7ba1\u5728\u5185\u90e8\u670d\u52a1\u5668\u4e2d \u9879\u76ee\u4e2d\u4f7f\u7528\u4e86\u516c\u5171\u4ed3\u5e93\u4e0a\u7684\u516c\u5171\u5305\uff0c\u4e5f\u4f7f\u7528\u4e86\u5185\u90e8\u670d\u52a1\u5668\u4e0a\u7684\u79c1\u6709\u5305 \u5e0c\u671b\u4e0b\u8f7d\u7684\u65f6\u5019\uff0c\u516c\u5171\u5305\u8d70\u516c\u5171\u4ed3\u5e93\uff0c\u79c1\u6709\u5305\u8d70\u5185\u90e8\u670d\u52a1\u5668\u7684\u79c1\u6709\u4ed3\u5e93 \u670d\u52a1\u5668\u786c\u76d8\u6709\u9650\uff0c\u5e0c\u671b\u53ea\u7f13\u5b58\u4e0b\u8f7d\u8fc7\u7684\u5305\uff0c\u800c\u4e0d\u662f\u5168\u90e8\u540c\u6b65\u3002 \u5bf9\u4e8e\u4e0b\u8f7d\uff0c\u53d1\u5e03npm\u5305\u6709\u5bf9\u5e94\u7684\u6743\u9650\u7ba1\u7406\uff0c\u5b89\u88c5\u65b9\u4fbf\uff0c\u914d\u7f6e\u7b80\u5355\uff0c\u4f9d\u8d56\u5c11\u3002 \u5173\u4e8esinopia\uff1f Sinopia\u00a0\u662f\u4e00\u4e2a\u96f6\u914d\u7f6e\u7684\u79c1\u6709\u7684\u5e26\u7f13\u5b58\u529f\u80fd\u7684npm\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4f5c\u8005\u662f\u662frlidwka\uff0c\u4e00\u4e2a\u5927\u795e\uff0c\u4e5f\u662f\u4e00\u53ea\u732b\uff5e \u5f80\u793e\u533a\u5185\u8d21\u732e\u8fc7\u5f88\u591a\u4ee3\u7801\uff0c\u5305\u62ec jshttp, markdown-it \u7b49\u7b49\uff0c\u4e5f\u662f Node.js \u6838\u5fc3\u4ee3\u7801\u5e93\u7684\u6d3b\u8dc3\u8d21\u732e\u8005\u3002 \u4f7f\u7528sinopia\uff0c\u4f60\u4e0d\u7528\u5b89\u88c5CouchDB\u6216MYSQL\u4e4b\u7c7b\u7684\u6570\u636e\u5e93\uff0cSinopia\u6709\u81ea\u5df1\u7684\u8ff7\u4f60\u6570\u636e\u5e93\uff0c\u5982\u679c\u8981\u4e0b\u8f7d\u7684\u5305\u4e0d\u5b58\u5728\uff0c\u5b83\u5c06\u81ea\u52a8\u53bb\u4f60\u914d\u7f6e\u7684npm\u5730\u5740\u4e0a\u53bb\u4e0b\u8f7d\uff0c\u800c\u4e14\u786c\u76d8\u4e2d\u53ea\u7f13\u5b58\u4f60\u73b0\u5728\u8fc7\u7684\u5305\uff0c\u4ee5\u8282\u7701\u7a7a\u95f4\u3002 \u4e3a\u4ec0\u4e48\u9009\u62e9sinopia sinopia\u6709\u4ee5\u4e0b\u51e0\u4e2a\u4f18\u52bf\u503c\u5f97\u5173\u6ce8\uff1a \u4e0d\u540c\u6b65\u62c9\u53d6npm\u5e93\uff0c\u5360\u636e\u5927\u91cf\u786c\u76d8\uff0c\u6ca1\u6709\u786c\u76d8\u88ab\u6491\u7206\u7684\u95ee\u9898\uff1b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-653","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=653"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/653\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}