Script which populates cache for any npm proxy by installing popular packages.
This script reads the top-npm-packages.json
file which contains a curated list of framework packages and their specific versions. For each package, it includes only the latest major version with the latest patch of each minor version. It then installs each package version to populate your npm proxy cache.
The top-npm-packages.json
file contains 874 package versions across 187 unique packages (averaging ~5 versions per package), including:
- Core Frameworks: React, Angular, Vue, Next.js, NestJS, Vite
- State Management: Redux, Zustand, Jotai, Recoil, @ngrx/store
- Routing: React Router, Angular Router
- Styling: Styled-components, Tailwind CSS, Emotion, Sass, Less
- Build Tools: Babel (full ecosystem), PostCSS, Webpack loaders
- Code Quality: ESLint (core + 20+ plugins & configs), Prettier
- TypeScript: 80+ @types packages for type definitions (including types for all major packages)
- Database ORMs: TypeORM, Mongoose, Sequelize
- Testing: Jest, Mocha, Testing Library types
- Server/API: Express, Passport, CORS types
- Utilities: Day.js, Lodash, UUID, classnames
- And many more related packages...
For each package, we include:
- Only the latest major version (e.g., v19 for React, not v18)
- Latest patch of each minor version (e.g., 19.2.0, 19.1.1, 19.0.0)
- Only stable releases (excludes pre-release versions like canary, alpha, beta, rc, next)
- Not all patch versions (excludes 19.2.1, 19.2.2, etc.)
Example: React 19.x.x
- Included:
19.2.0
(latest patch of 19.2),19.1.1
(latest patch of 19.1),19.0.0
(latest patch of 19.0) - Excluded: All React 18.x.x versions, intermediate patches, and pre-release versions (e.g., 19.3.0-canary)
This strategy provides good coverage of stable releases while keeping the cache size manageable.
-
Configure npm registry:
npm config set registry {your private registry url}
-
Run the script:
node index.js
--sleep={s}
- Timeout in seconds between each package installation (default: 0)--start={s}
- Index of package version to start from (default: 0)
Install all packages from the beginning:
node index.js
Install all packages with 1 second delay between each:
node index.js --sleep=1
Continue from a specific index (e.g., after interruption):
node index.js --start=5000 --sleep=1
Install in batches (recommended for large sets):
# First batch: 0-1000
node index.js --start=0 --sleep=1
# Stop with Ctrl+C when done, then continue...
# Second batch: 1000-2000
node index.js --start=1000 --sleep=1
# Third batch: 2000-3000
node index.js --start=2000 --sleep=1
# ... continue until all 874 packages are processed
- The script processes all packages from the
--start
index to the end - The script installs and then immediately removes each package to populate the cache
- Only packages compatible with your installed Node.js version will be cached
- Failed installations are logged but don't stop the process
- Use
--sleep
parameter to avoid overwhelming your registry or network - Use Ctrl+C to stop the script at any time, then resume with
--start
parameter
To check for and add new versions to your package list, run:
node update-list.js
This script will:
- Check each package for new versions on npm registry
- Update existing minor versions if newer patches are available
- Add new minor versions within the current major version
- Add new major versions with all their minor versions (latest patch each)
- Create a timestamped backup before making changes
The update process preserves the version strategy (latest major, latest patch per minor).
- Node.js >= v16.16.0
- npm >= 6.14