Skip to main content

3 posts tagged with "yarn"

View All Tags

· One min read
MengFei

https://github.com/nodesource/distributions

常用

Debian and Ubuntu based distributions

# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs

Enterprise Linux based distributions

Run on RHEL, CentOS, CloudLinux, Amazon Linux or Fedora:

# As root
curl -fsSL https://rpm.nodesource.com/setup_14.x | bash -

# No root privileges
curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -

· 2 min read
MengFei

NPM: https://www.npmjs.com/package/ynrm Github: https://github.com/mengfei0053/ynrm.git

Fork了狼叔yrm做了一些修改, 可以同时更改yarn 和npm 当前用户的源。

Ynrm 和. Nrm/Yrm

  • 用 typescript 重写了一下
  • 将npm从依赖中移除, 通过npm root -g,获取本机的npm
  • 使用axios替换request

安装

$ npm install -g ynrm

Example

ynrm 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
skimdb -- https://skimdb.npmjs.com/registry
yarn ---- https://registry.yarnpkg.com

# ynrm will set up both npm registy and yarn registry
# switch registry to taobao registry
ynrm use cnpm # 使用源

YARN Registry has been set to: https://registry.npm.taobao.org/

NPM Registry has been set to: https://registry.npm.taobao.org/

ynrm add custom_registry https://custom_registry.xx.com # 添加仓库源
ynrm del custom_registry # 删除仓库源
ynrm test # 测试仓库源链接速度

Usage

Usage: ynrm [options] [command]

Commands:

ls List all the registries
use <registry> Change registry to registry
add <registry> <url> [home] Add one custom registry
del <registry> Delete one custom registry
home <registry> [browser] Open the homepage of registry with optional browser
test [registry] Show the response time for one or all registries
help Print this help

Options:

-h, --help output usage information
-V, --version output the version number

默认可选仓库源

· One min read
MengFei

npm & yarn

yarn info <pkg>  #查看远端仓库 pkg 包信息, 后面可跟 package.json 中字段查看具体信息
yarn info <pkg> version # 当前版本
yarn info <pkg> versions # 版本列表
yarn info <pkg> engines # 依赖的 node版本,或npm 版本, yarn 版本等等
yarn info <pkg> dependencies
yarn info <pkg> devDependencies
yarn info <pkg> peerDependencies
yarn why <pkg> # 查看项目有没有包 pkg, 会列出包版本和被谁依赖
yarn