Skip to content

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

  1. Create a .npmrc file
  2. Initialization the pnpm init
  3. Add Script
  4. 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.

Initialization the pnpm init
Initialization the 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.

Run pnpm test command
Run pnpm test command

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.

Check the nodejs version in the terminal
Source: https://medium.com/frontendweb/how-to-manage-multiple-nodejs-versions-with-pnpm-8bcce90abedb
See also  Get file size in Node.js

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.