Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm 知识合集 #10

Open
tinet-jutt opened this issue May 7, 2021 · 0 comments
Open

npm 知识合集 #10

tinet-jutt opened this issue May 7, 2021 · 0 comments
Labels

Comments

@tinet-jutt
Copy link
Owner

tinet-jutt commented May 7, 2021

npm 知识合集

  • npm换源的几种方式

  1. 使用nrm
    • 安装
    npm install -g nrm
    
    • 列出源的列表
    nrm ls
    
    • 输出结果
    * npm ---- https://registry.npmjs.org/
      cnpm --- http://r.cnpmjs.org/
      taobao - https://registry.npm.taobao.org/
      nj ----- https://registry.nodejitsu.com/
      rednpm - http://registry.mirror.cqupt.edu.cn/
      npmMirror  https://skimdb.npmjs.com/registry/
      edunpm - http://registry.enpmjs.org/
    
    • 使用
    nrm use taobao
    
  2. 改变全局的注册
    • 设置成淘宝源
    npm config set registry https://registry.npm.taobao.org
    
    可使用npm config set @myco:registry =<url register myco>为不同包范围注册不同的包地址
    • 查看结果
    npm config get registry
    
    • 输出结果:
    https://registry.npm.taobao.org/
    
    测试一下(npm info [packageName] 查看指定包的详情)
    npm info vue
    
  3. 在命令行里指定源
npm --registry https://registry.npm.taobao.org install [name]
  1. 修改全局.npmrc 文件位于 ~/.npmrc
registry = https://registry.npm.taobao.org

为不同包范围注册不同的包地址

@myco:registry=<url register A>
registry=<url register B>

@myco开头的包的注册地址是A,其余的包注册地址是B

@tinet-jutt tinet-jutt added the NPM label May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant