Thursday | 25 APR 2024
[ previous ]
[ next ]

Switching from npm to pnpm

Title:
Date: 2023-01-23
Tags:  

Now that I'm doing more and more javascript projects, I'm getting tired of constantly installing better-sqlite3. I keep needing to re-installing it and it's always a pain. I decided to switch to using pnpm so that it would re-use packages that are already saved.

This should speed up my installation step.

Luckily pnpm is pretty much a drop in replacement for npm so most commands can just be replaced with pnpm instead of npm.

Installing it is as easy as pwning yourself:

curl -fsSL https://get.pnpm.io/install.sh | sh -

Getting it to install better-sqlite3 on CentOS 7.4 was a bit more cumbersome. I had to first install node-gyp and then make sure my environment had access to a newer gcc.

node_modules/.pnpm/better-sqlite3@8.0.1/node_modules/better-sqlite3: Running install script...
 ELIFECYCLE  Command failed.

This was the error I got, not very clear but ultimately it was because node-gyp was unavailable.

After all this trouble though I can now install better-sqlite3 in seconds instead of minutes.