npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fanwang/pack-util

v3.2.1

Published

Pack all installed package in ./node_modules, and publish to Nexus self-hosted Registry.

Downloads

23

Readme

pack-util

中文 | English

一个打包工具,可以在互联网网机器上将项目 ./node_modules 中安装的包遍历后打包,并放在 ./node_modules_pack 文件夹中,并批量上传到 nexus 搭建的 npm 私服上。支持 pnpm/yarn/npm 打包工具。

安装

全局安装即可。

npm install -g @fanwang/pack-util

使用

使用说明

如果使用控制台命令的时候提示电脑禁止运行脚本,用管理员身份运行 cmd 或者 vscode 等然后在命令行输入:

Set-ExecutionPolicy RemoteSigned

建议先将源仓库设为阿里镜像仓库,这样打包速度更快(yarn 和 npm 需要同时设置):

yarn config set registry https://registry.npmmirror.com
npm config set registry https://registry.npmmirror.com

第一步. 将项目所有依赖包下载至 ./node_modules_pack 文件夹

cd your_project
pack-util pack
# 选择所使用的包管理工具即可( pnpm | yarn | npm )

解释: 工具是根据你使用的包管理工具来检索项目的所有依赖包。

  • pnpm: 根据 pnpm-lock.yaml 文件来检索
  • yarn: 根据 yarn.lock 文件来检索
  • npm: 根据 npm list --all 的输出来检索

因此,如果单纯的想从互联网下载一些包,可以仅凭一个 package.json 文件,利用不同的包管理工具执行 install 得到相应的检索文件后,就可以执行 pack 操作了。甚至建立一个空文件夹,然后通过 yarn add | pnpm add | npm install 添加自己需要的包来直接得到检索文件,也是可以的。

第二步. 将依赖包批量上传到 nexus 搭建的 npm 私服上

  1. 将 ./node_modules_pack 文件夹和你的项目一起拷贝至内网机器上,然后执行上传。
cd your_project
pack-util upload

解释: 工具是在命令执行目录下查找 ./node_modules_pack 文件夹,然后把文件夹中的包批量上传,所以只需要把 ./node_modules_pack 文件夹拷贝到命令执行目录即可。

  1. 输入参数
? Please input your Nexus url host (eg: http://xx.xx.xx.xx:xxxx): http://xx.xx.xx.xx:8081/
? Please input your Nexus npm repository (eg: localNpm):  localNpm
? login to Nexus by username:  admin
? password:  [hidden]
  1. 如果出现上传失败,删除其他成功上传的包,然后重新执行上传(也可以直接重试上传)。

第三步. 在内网机器上执行包依赖安装

先删除 yarn.lock / package-lock.json / pnpm-lock.yaml 文件。

PNPM

pnpm config set registry http://xx.xx.xx.xx:xxxx/repository/localNpm/
pnpm install

YARN

yarn config set registry http://xx.xx.xx.xx:xxxx/repository/localNpm/
yarn install

NPM

npm config set registry http://xx.xx.xx.xx:xxxx/repository/localNpm/
npm install --save --legacy-peer-deps  # 注意:在私网上安装 npm 包需要忽略对 peer 依赖