FNPM (WIP)
FNPM is an "alternative" for NPM, it is faster and saves more space.
DISCLAIMER
This project was made to learn more about Package Managers, for now you should only use it to play with it.
Requirements
- Node v16 or higher
- Linux or Mac OS (Working on Windows support issue)
CLI
The FNPM CLI is used to install packages from the package.json of a project.
Its advantages are that it is faster than NPM and saves more space.
Instalation
npm i @fnpm-io/cli -g
Commands
fnpm install [pkg (optional), flags]
Installs packagesfnpm run <script> <params>
Run script from package.jsonfnpm create <template> <arguments>
Create a project from a template (Similar to npm init)fnpm benchmark
Tests SNPM against NPM and PNPMfnpm clear
Remove .snpm-cache folderfnpm ls <pkg>
Show versions installed by SNPM
Todo
- Make it work in some JS Frameworks (Follow progress here)
- Fix monorepos integration (WIP, degradated performance in some repos)
Why is it faster?
SNPM uses the same installation system as PNPM, fetch dependency, download dependency. Without waiting for the rest of the dependencies.
Now you are probably wondering how that makes the space more efficient than in NPM.
Each dependency is a hard link to a common store inside .fnpm-cache
, so all your projects use shared dependencies.
It works?
Short answer, probably no, but in some cases it works. (For now)
I've selected some quickstart templates to test SNPM, and I'm working on make it work in all of them.
If you want to test a template, you can use Next or Vite, I've already tested them and it should work.
(If you want to test a template and it doesn't work, please open an issue)
Benchmarks
Nextjs - TS
This example is generated using npx create-next-app --use-npm --ts
WARNING: It works now, but some errors may appear.
Node.js: v18.4.0
OS: linux
FNPM version: 0.4.0
Current project: fnpm-next-test (0.1.0)
โโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโ
โ (index) โ name โ time โ group โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโค
โ 0 โ 'Bun install (with cache / with lockfile)' โ '0.17s' โ 3 โ
โ 1 โ 'Bun install (with cache / no lockfile)' โ '3.83s' โ 2 โ
โ 2 โ 'FNPM install (with cache)' โ '4.41s' โ 3 โ
โ 3 โ 'PNPM install (with cache)' โ '4.66s' โ 3 โ
โ 4 โ 'YARN install (with cache)' โ '5.56s' โ 3 โ
โ 5 โ 'NPM install (with cache / with lockfile)' โ '7.01s' โ 3 โ
โ 6 โ 'NPM install (with cache / no lockfile)' โ '8.30s' โ 2 โ
โ 7 โ 'Bun install (no cache / no lockfile)' โ '8.85s' โ 1 โ
โ 8 โ 'YARN install (with cache, no lock)' โ '10.57s' โ 2 โ
โ 9 โ 'FNPM install (no cache)' โ '19.59s' โ 1 โ
โ 10 โ 'NPM install (no cache / no lockfile)' โ '25.20s' โ 1 โ
โ 11 โ 'YARN install (no cache, no lockfile)' โ '30.00s' โ 1 โ
โ 12 โ 'PNPM install (no cache)' โ '45.77s' โ 1 โ
โโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโ
The commands with no-cache executes npm cache clean -f
to delete NPM Cache files (SNPM uses them too npm/pacote) and also deletes the store folder for FNPM.