Transitioning from using lerna to adopting pnpm

We are in the process of transitioning our project from Lerna to PNPM and we currently have a script that we run. Here are the commands:

"postinstall": "npm run bootstrap"
"bootstrap": "lerna bootstrap --hoist",
"clean": "lerna clean -y",

I'm wondering if there is an equivalent command in PNPM for both 'lerna bootstrap' and 'lerna clean'?

Answer №1

Starting without the need for a Lerna bootstrap equivalent, simply dive into pnpm workspace which is quite straightforward. All you have to do is include a pnpm-workspace.yaml file in your project's root directory and specify the location of your packages (usually packages/). As stated in the pnpm documentation:

A workspace must contain a pnpm-workspace.yaml file in its main directory. Additionally, a workspace can also have an .npmrc file in its root.

Hoisting is not recommended with pnpm by default, but if hoisting is desired, you can include shamefully-hoist in the .npmrc file as explained in the pnpm doc - shamefully-hoist

By default, pnpm generates a strict layout of node_modules, allowing dependencies access to undeclared dependencies while restricting modules outside of node_modules. This setup works seamlessly with most packages in the ecosystem. But, if certain tools require hoisted dependencies at the root level of node_modules, setting this option to true will handle the hoisting automatically.

I'm unsure about an exact equivalent of lerna clean, but to eliminate a dependency from the node module, you can utilize pnpm remove --recursive according to the pnpm doc - remove

When used within a workspace (with --recursive), removes a dependency (or dependencies) from every package within the workspace.

When used outside of a workspace, removes a dependency (or dependencies) from all packages located in subdirectories.

You can observe an illustration of these practices in Lerna-Lite's pnpm-workspace.yaml and it may be beneficial to explore Lerna-Lite without completely abandoning Lerna. I developed a Lerna-Lite fork when Lerna ceased to receive maintenance updates (although it does now). The key differences lie in Lerna-Lite featuring only a subset of the original Lerna commands (omitting commands handled more efficiently by other package managers), alongside being significantly smaller due to some commands being offered as optional packages, retaining only version and publish in the core CLI. Personally, I disagree with the recent changes in Lerna's direction wherein it reflects similarities to Nrwl/Nx products; whereas Lerna-Lite remains devoid of such influences. Nx remains installable with Lerna-Lite but is entirely optional, maintaining the essence and focus on simplicity inherent to Lerna-Lite).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

onmouseleave event stops triggering after blur event

I am facing an issue with a mouseleave event. Initially, when the page loads, the mouseleave event functions correctly. However, after clicking on the searchBar (click event), and then clicking outside of it (blur event), the mouseleave functionality stops ...

Obtain the VW/VH coordinates from an onclick action in JavaScript

With this code snippet, you'll be able to retrieve the x and y coordinates of a click in pixels: document.getElementById("game").addEventListener("click", function(event) { console.log(event.clientX, event.clientY); }); However ...

Does the built-in waiting mechanism in Protractor automatically handle promises?

While browsing through Stack Overflow, I stumbled upon this response in a discussion about Protractor tests and asynchronous solutions: 'AFAIK expect waits internally for the related promises.' I have tried looking through the official Protract ...

Running a JS/JSON function in Snowflake that results in a syntax error

Can anyone help me troubleshoot the issue with the following function? I am receiving this error message: SQL compilation error: syntax error line 1 at position 0 unexpected 'function'. Should I be using JSON Script or Javascript for this? func ...

Launch both client and server simultaneously with a single command by utilizing Vue-cli and Webpack

Currently, I am setting up a Vue client with Vue-cli 3 that utilizes Webpack. (To start the client, I run "yarn dev --open") In addition, I am developing a server with an API for the client. (To run the server, I execute "node server/server.js") Is th ...

Using d3 or ajax to read a local file containing tab-separated values may result in a syntax error appearing in the Firefox development console

The reading operation is functioning as expected. However, I encountered a syntax error in the Firefox console while going through multiple files, which can be quite tedious. These files are annotation files formatted like (time \t value) with no head ...

When `rxjs` repeat and async pipe are applied and then removed from the DOM, the resulting value becomes null

One of the classes I have is responsible for managing a timer. It contains an observable that looks like this: merge( this._start$, this._pause$ ) .pipe( switchMap(val => (val ? interval(1000) : EMPTY)), map( ...

dynamically change the information in AngularJS

I need to work with two different endpoints: http://localhost:3000/entry (POST) The keys required are: fname, lname, and age. To submit a form, we have to send a POST request to this URL. http://localhost:3000/entries (GET) This endpoint will retrieve ...

Is it possible to add my own designs to a three.js model?

I am looking to add some personal touches to my three.js model by drawing on it in the scene. How can I achieve this effect of 'graffiti' on my models within the scene? ...

Is the jQuery form plugin not passing any data to Node.js?

Check out the HTML form below: <form id="importForm" enctype="multipart/form-data"> <p> <label for="ownerName">Owner Name<pow class="requiredForm ...

Error in Node.js (NPM Error)

Recently, I purchased a VPS running Ubuntu 14.4 and successfully installed Node.js 1.4. However, when attempting to run my script (node tradebot.js), I encountered the following error message! :-/ module.js:327 throw err; ^ Error: Cannot find ...

Display a few HTML elements sourced from a different online platform

I am trying to extract a specific value from a span element on another website and render it on my own website using either a GET/FETCH request or some other method. Currently, I have this code but I am struggling to extract the data I need. The data I am ...

Instructions for sending an array of integers as an argument from JavaScript to Python

I have a JavaScript function that extracts the values of multiple checkboxes and stores them in an array: var selectedValues = $('.item:checked').map(function(){return parseInt($(this).attr('name'));}).get(); My goal is to pass this a ...

Tips for creating a clickable A href link in the menu bar that triggers an accordion to open in the body when clicked - html

Is there a way to open the first accordion when clicking on the "open 1st accordion" link, and do the same for the second link? The accordions themselves work perfectly fine, I just need a way to trigger them from outside their scope by clicking on links i ...

When utilizing the React API Fetch, there may be instances where not all data is returned. However

Having some trouble with my FetchData class. I am receiving a list of data, but it's in an array format. When I try to access specific values like countries: data.Countries[0], I can get individual values based on the index. However, what I really wan ...

Issues have arisen with the execution of JavaScript code inside a callback function

When the warnBeforeNew variable is set to false in the JavaScript code below, the file open function works as expected. However, when warnBeforeNew is true, an error occurs stating "Uncaught TypeError: Cannot read property 'root' of undefined". ...

Exploring the Battle of Efficiency: Stateless Components vs. Class Components in the Age of React Hooks - Determining the Superior Approach

Having delved into various online resources and discussions on platforms like Stack Overflow (link here), the consensus seems to lean towards utilizing stateless functions (functional components) whenever possible. Many of the life cycle methods found in ...

Incorporating FaceBook into a PhoneGap Application

Currently, I am working on integrating Facebook into my phonegap/cordova application. To guide me through the process, I am using the resources provided in this link: https://github.com/davejohnson/phonegap-plugin-facebook-connect/ Even though I have bee ...

Choose the appropriate NPM module platform for Angular development

My Angular application runs smoothly in Chrome, but encounters errors on Internet Explorer. The issue arises from the different distributions of NPM modules I install. For instance, within the kendo-angular-charts folder, we have: - dist |- cdn |- e ...

How to set environment variables in npm on Windows Command Prompt (command not recognized as internal or external command)

What is the correct way to set environment variables in a command line script on Windows? MY_ENV_VAR=2 npm run my_script or MY_VAR1=100 MY_VAR2=300 npm run my_script I am trying to define environment variables for my script. In my index.js file, I have ...