How to Fix the WordPress White Screen of Deat
The WordPress White Screen of Death (WSOD) is one of th...
PNPM (Performant NPM) is a fast, disk space-efficient package manager for Node.js. Compared to traditional NPM or Yarn, PNPM uses a clever strategy to store packages in a central content-addressable storage, resulting in faster installations and reduced disk space usage. If you’re looking for a lightweight, fast alternative to NPM, PNPM is a great choice.
This guide will walk you through the installation process and how to use PNPM on Linux.
PNPM is a package manager similar to NPM and Yarn, but with several key differences:
Before installing PNPM, it's a good idea to update your system's package list to ensure all tools are up to date. Run the following commands:
sudo apt-get update
sudo apt-get upgrade -y
This updates the system repositories and upgrades existing packages.
PNPM requires Node.js to run. If you don’t have Node.js installed, you can install it using the NodeSource repository. Run the following commands to install the latest stable version of Node.js:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
Verify that Node.js and NPM are installed by running:
node -v
npm -v
You should see output similar to:
v18.17.0
8.11.0
This confirms that Node.js and NPM have been installed successfully.
There are several ways to install PNPM, but the simplest method is to use the following script:
curl -fsSL https://get.pnpm.io/install.sh | sh -
Note: This script will install PNPM in your user's home directory (
~/.local/share/pnpm
).
After the installation is complete, add PNPM to your system's PATH by adding the following line to your ~/.bashrc or ~/.zshrc file:
export PATH="$HOME/.local/share/pnpm:$PATH"
Apply the changes to your current session with:
source ~/.bashrc
To verify the installation, run:
pnpm -v
If the command returns a version number, PNPM has been installed successfully.
PNPM works similarly to NPM, so you can use familiar commands to manage Node.js packages. Here are some key PNPM commands to get you started:
Command | Description |
---|---|
pnpm init | Initializes a new project (like npm init ) |
pnpm install | Installs all dependencies listed in package.json |
pnpm install <pkg> | Installs a specific package |
pnpm add <pkg> | Adds a package to dependencies |
pnpm add -D <pkg> | Adds a package to devDependencies |
pnpm remove <pkg> | Removes a specific package |
pnpm update | Updates all installed packages |
Example 1: Install a specific package (like Express):
pnpm add express
Example 2: Install a package as a development dependency:
pnpm add -D eslint
One of PNPM's strengths is its support for monorepos. A monorepo allows multiple projects to exist within a single repository, and PNPM makes managing shared dependencies across these projects much easier.
To create a monorepo using PNPM, follow these steps:
mkdir my-monorepo cd my-monorepo
packages: - 'packages/*'
mkdir -p packages/project-a mkdir -p packages/project-b
cd packages/project-a pnpm init -y
Now you can manage all dependencies for the monorepo in one place.
To update PNPM to the latest version, use the following command:
pnpm add -g pnpm
You can also check for updates with:
pnpm --version
This ensures that you’re using the latest version of PNPM with the newest features and performance improvements.
Feature | PNPM | NPM | Yarn |
---|---|---|---|
Speed | ✅ Faster | ⚠️ Slower | ⚠️ Slower |
Disk Usage | ✅ Lower | ⚠️ Higher | ⚠️ Higher |
Monorepo Support | ✅ Best-in-class | ⚠️ Limited | ✅ Good |
Offline Mode | ✅ Supported | ⚠️ Limited | ✅ Supported |
Why Choose PNPM?
If you need a fast, reliable server for your Node.js, PNPM, or monorepo projects, SurferCloud is an excellent choice. SurferCloud offers high-performance, globally distributed servers with data centers in Asia, Europe, and the Americas. Whether you need a VPS to deploy your Node.js app or a development environment for monorepos, SurferCloud has you covered. With affordable pricing and 16 global server locations, you can enjoy fast performance and low latency wherever you are.
The WordPress White Screen of Death (WSOD) is one of th...
The ps aux command in Linux is an essential tool for mo...
Knowing whether your Linux system is 32-bit or 64-bit i...