Advertisement
Guest User

Untitled

a guest
May 24th, 2016
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.63 KB | None | 0 0
  1. # ================================
  2. # Install cnpmjs.org and dependencies
  3.  
  4. $ npm install -g --build-from-source \
  5.    --registry=https://registry.npm.taobao.org \
  6.    --disturl=https://npm.taobao.org/mirrors/node \
  7.    cnpmjs.org cnpm sqlite3
  8.  
  9. # ================================
  10. # Start local cnpmjs.org
  11.  
  12. $ nohup cnpmjs.org start --admins='myname' \
  13.   --scopes='@my-company-name'
  14.  
  15. # ================================
  16. # Login (and create account) to my private registry using admin account
  17.  
  18. $ npm login --registry http://127.0.0.1:7001 --scope=@my-company-name
  19. Username: myname
  20. Password:
  21. Email: (this IS public) myname@example.com
  22. Logged in as myname to scope @my-company-name on http://127.0.0.1:7001/.
  23.  
  24. # ================================
  25. # Let's see what happened to .npmrc
  26.  
  27. $ cat ~/.npmrc
  28. xxxxxxxxx
  29. @my-company-name:registry=http://127.0.0.1:7001/
  30. //127.0.0.1:7001/:_password="xxxxxxxxx"
  31. //127.0.0.1:7001/:username=myname
  32. //127.0.0.1:7001/:email=myname@example.com
  33. //127.0.0.1:7001/:always-auth=false
  34.  
  35. # ================================
  36. # Let's upload a private package
  37.  
  38. $ mkdir example_private_module && cd example_private_module
  39.  
  40. $ npm init
  41.  
  42. $ cat package.json
  43. {
  44.   "name": "@my-company-name/example_private_module",
  45.   "version": "1.0.0",
  46.   "description": "",
  47.   "main": "index.js",
  48.   "scripts": {
  49.     "test": "echo \"Error: no test specified\" && exit 1"
  50.   },
  51.   "author": "",
  52.   "license": "ISC"
  53. }
  54.  
  55. $ echo "module.exports = 'hello';" > index.js
  56.  
  57. # ================================
  58. # Publish the private package to our private registry
  59.  
  60. $ npm publish
  61. + @my-company-name/example_private_module@1.0.0
  62.  
  63. # ================================
  64. # Now let's use this private package in a project
  65.  
  66. $ cd .. && mkdir example_project && cd example_project
  67.  
  68. $ npm install optimist @my-company-name/example_private_module
  69. /Users/Breezewish/Desktop/cnpm/example_project
  70. ├── @my-company-name/example_private_module@1.0.0
  71. └─┬ optimist@0.6.1
  72.   ├── minimist@0.0.10
  73.   └── wordwrap@0.0.3
  74.  
  75. # ================================
  76. # cnpm will not success, because cnpm use a different npmrc
  77.  
  78. $ cnpm install optimist @my-company-name/example_private_module
  79. npm ERR! Darwin 14.5.0
  80. npm ERR! argv "/usr/local/Cellar/node/5.8.0/bin/node" "/usr/local/bin/npm" "--registry=https://registry.npm.taobao.org" "--cache=/Users/Breezewish/.npm/.cache/cnpm" "--disturl=https://npm.taobao.org/dist" "--userconfig=/Users/Breezewish/.cnpmrc" "install" "optimist" "@my-company-name/example_private_module"
  81. npm ERR! node v5.8.0
  82. npm ERR! npm  v3.7.3
  83. npm ERR! code E404
  84.  
  85. npm ERR! 404 Not Found: @my-company-name/example_private_module
  86. npm ERR! 404
  87. npm ERR! 404  '@my-company-name/example_private_module' is not in the npm registry.
  88. npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
  89. npm ERR! 404
  90. npm ERR! 404 Note that you can also install from a
  91. npm ERR! 404 tarball, folder, http url, or git url.
  92.  
  93. npm ERR! Please include the following file with any support request:
  94. npm ERR!     /Users/Breezewish/Desktop/cnpm/example_project/npm-debug.log
  95.  
  96. # ================================
  97. # Let's make cnpm working!
  98.  
  99. $ npm login --registry http://127.0.0.1:7001 --scope=@my-company-name --userconfig=$HOME/.cnpmrc
  100. Username: myname
  101. Password:
  102. Email: (this IS public) myname@example.com
  103. Logged in as myname to scope @my-company-name on http://127.0.0.1:7001/.
  104.  
  105. # ================================
  106. # TADA! Everything works!
  107.  
  108. $ cnpm install optimist @my-company-name/example_private_module
  109. /Users/Breezewish/Desktop/cnpm/example_project
  110. ├── @my-company-name/example_private_module@1.0.0
  111. └── optimist@0.6.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement