本地下载安装包

如果你想依赖你自己模块中的包,你可以在本地 安装 一个包,使用 Node.js require 之类的东西。这是 npm install 的默认行为。

安装无范围的包

无范围的包始终是公开的,这意味着任何人都可以搜索、下载和安装它们。要安装公共包,请在命令行上运行

npm install <package_name>

这将在您的当前目录中创建 node_modules 目录(如果尚不存在)并将包下载到该目录。

注意:如果本地目录下没有 package.json 文件,则安装最新版本的包。

如果有 package.json 文件,npm 会安装满足 package.json 中声明的 semver 规则 的最新版本。

安装范围公共包

gCd2CLlBvLtTRY1K8d+0jmsQKWZUg9ciU1zcMb5cBmfVk7quD3SmDB2d4zYgNMoRkXIp1lD9K/ypaVusc/VDvVMYKZsJfNzZvkzE5MhkFlCoYWSJ+4QzXm8S3FJXypVdcwi7rXSm+YXqc5UbirXKdHPGTLoGB4kofVSfSoTOYJYjsNQt5s+lZtlB4b5LmF+d29tUyeAVTP1xYC8ITLNo/Q==

npm install @scope/package-name

安装私有包

uaepsnsC+3bEMUBy67j1S+KBH8/bpICKNhwgjyeaq0hwj5JClu0fOFwayR88UAtM8guES+azoUq3/ekKpuU19t61MfSAcEkpaZ8esziuSHO+KuhqvUMmOTXy7KdoB2N21MoMkTyV0Tgr4hcS797XiVHKOuiy0/IyDkOuSv0frdtMuhYOG1l89C1aT9Q+28yn2OG4z5C+o8/7l8AtvFqKUOIfj6YPyAWcU8v2vbg4ANrHLCCiuu36EP21o6wmQMQEhNLnJ2sItcn8sl2yX9dql7s/uoxnS5VR2zn+X5vx6t0=

npm install @scope/private-package-name

测试包安装

NiiTC/M+9kvbq6h1H0+pVxacAqxt+xpTA44tIqhVCCAf53y/5CiXTONliVpr9flEBAxEzaAaoKvx6S44PslT5Sjh5L3IzIock7exWR+pL6Cm39yYxTARwAkFH+ZX5tdNrcMmRz+8brQiV4JEo+dQzJ625zTEPODUijLK2kMUJfgj56gaQgRwjL0J1+RMTulFjElUQaRQfUGi3tE2NQC6MCNDgduLFiNzVU2vggNHDh5+dYFdxqC8ou7UpXLK4tgQ

ls node_modules

安装的包版本

7HKgDGET8hQsKZASnbI4Iy/XbE56+9glNEXz59CoJfuUGrZpWOsMzw6PAa4MWG2KVOWYu/ulZVgm/S/9buswL3Py4b41H6RBitEiBDjL84nfOXkQj6JOPICPBNizdm/8qMR/fjV56/5Lfg9VpbSfFt3BsgGh39sLYeLA55XOI/AY2xz5tfkkCYlNb7hdBzTagz/xxxJqp9RTiNZzJ6FkAfer246mOpVx3sj1kLZZMYgy1D7XdWyiNWNBh+s9NpXZ5hNHpURolCKZtD4dzhTq3J1artqaPeRfUlPNi87g4SF/Dd3C7dF3e8Q5s7EM/IlO27CeAXIn1TxdSMNrMevTxg==

CnysbVDhrGmVML1ZURdMgeyUJdIMfK1dCrNQD192DFENhDERaSPXTwMDs3PEksSvkYntj9xtubYwa92hgxv4Z5ShHx3JGuv7v6WWTy9fFGs=

使用 dist-tags 安装包

RLSuR0UhXeCeGVqu9NSSfQ5lmUupK6MlesBLxOkRcm03pqRurFlpjFtKkoJeKG3fZvW0xhm6J7zOEzY21m0ec3PkbIjjji1J6Qf7S1XhdVFlXbXV0T/O6ddY+mGzMhpZHBti24NU+UdYqI18S66QHBUeVaZb+PnQ7pI/607kbAU=

2X4dMBcSrEI42mlq9O0SGccS3TMrK1zA0cJ9b9hsEXxwaQqs2zbgSME1z8HvcrVZgzbNSywN9aIZjQZNGmlPC/81K3Nfoncpp0AWQuL7JO+YgatP1y7zJxcptLevxFzBrA3brTbeu9ZcP5SIMMjdZC++5t1xPFgDftNYDBp30oT8VH1bnpaV1eVOOj8vP+PJeW2UdadfnJU9ojwyWBQP5bPc+97WlzUW8qwkvGIdvQNeUVHZ1DuhHO8jIfhjWnwebF2XH5citlqgfL8E7yR9pwQMxTM9xK5qeNjamBq4/VA=

npm install example-package@beta

资源

A6K8TiLxneCgMboBwWAC9TDVvTl3RJMAZ4IT+j3HGioRXou8OHsQhANgvn0bJmlY90Ytbd0Z3xO/T0drlrbsOne/2AxsHYrxfuXHFKcL2TBcVJ/qT2AzjxnTZmImtccefsJVzs/YPKTLwgoW/R01AQ==