pnpm tricks

pnpm tips and tricks

pnpm is a package manager for Node.js. It saves and caches the dependencies of your project. It does not install packages, if they are already installed by another project rather re-use the same packages thus saves lot of space on your disk.


$ pnpm install react-router --save

ERR_PNPM_UNEXPECTED_STORE  Unexpected store location

The dependencies at "/Users/sam/Dev/react-all-in-one/node_modules" are currently linked from the store at "/Users/XXXXX/Library/pnpm/store/v3".

pnpm now wants to use the store at "/Users/sam/Library/pnpm/store/v3" to link dependencies.

If you want to use the new store location, reinstall your dependencies with "pnpm install".

You may change the global store location by running "pnpm config set store-dir <dir> --global".
(This error may happen if the node_modules was installed with a different major version of pnpm)

pnpm install


? The modules directory at "/Users/sam/Dev/react-all-in-one/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) › true
   ╭──────────────────────────────────────────────────────────────────╮
   │                                                                  │
   │                Update available! 8.12.1 → 8.13.1.                │
   │   Changelog: https://github.com/pnpm/pnpm/releases/tag/v8.13.1   │
   │                Run "pnpm add -g pnpm" to update.                 │
   │                                                                  │
   │      Follow @pnpmjs for updates: https://twitter.com/pnpmjs      │
   │                                                                  │
   ╰──────────────────────────────────────────────────────────────────╯

✔ The modules directory at "/Users/sam/Dev/react-all-in-one/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) · true
Recreating /Users/sam/Dev/react-all-in-one/node_modules
Lockfile is up to date, resolution step is skipped
Packages: +1902
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Downloading registry.npmjs.org/react-icons/4.11.0: 21.06 MB/21.06 MB, done
Downloading registry.npmjs.org/@swc/core-darwin-arm64/1.3.92: 12.95 MB/12.95 MB, done
Progress: resolved 1902, reused 1139, downloaded 760, added 1902, done
node_modules/.pnpm/core-js-pure@3.33.0/node_modules/core-js-pure: Running postinstall script, done in 60ms
node_modules/.pnpm/core-js@3.33.0/node_modules/core-js: Running postinstall script, done in 50ms
node_modules/.pnpm/@swc+core@1.3.92/node_modules/@swc/core: Running postinstall script, done in 53ms

Done in 50.4s