How to install a specific nodejs version according to the workspace with pnpm?
You install a particular version of nodejs according to a workspace with pnpm. For installation, you need a .npmrc
file.
Steps
- Create a
.npmrc
file - Initialization the
pnpm init
- Add Script
- Run
pnpm test
Create a .npmrc
file
The first step is to create a .npmrc
file in the root folder.
.npmrc
use-node-version=11.15.0
Initialization the pnpm init
The Initialization of the new project with pnpm init
command. The pnpm init command creates a new package.json file.

pnpm init
Add Script
You can replace scripts with the package.json file.
"scripts": { "test": "node -v"},
Run pnpm test
In the end, you can run pnpm test
command and your output look like this.

Note
In the terminal, you run node -v
in the same working folder and without pnpm, your node -v
version print defiantly in the terminal.
