The process of installing dependencies recursively using pnpm

In my monorepo project, I have workspaces A and B. Workspace A depends on B being built first, with each workspace in its own folder as defined in pnpm-workspace.yaml

packages:
 - 'src/mydepa'
 - 'src/mydepb'
{
   "name": "@mydep/a",
   "scripts": {
      "build": "standard build script"
   }
}
{
   "name": "@mydep/b",
   "scripts": {
      "build": "standard build script"
   },
   "dependencies: {
      "@mydep/a": "link:../mydepb
   }
}

I'm struggling to figure out how to instruct pnpm to build A before B (and C and D). When using standard npm, the order of workspace packages determines the build execution. I remove the workspaces entry from the root package.json before running pnpm.

"workspaces": [
    "src/mydepa",
    "src/mydepb",
],

Even after trying different methods like:

pnpm run --recursive --workspace-concurrency=1 --aggregate-output --report-summary build

I found that pnpm continues to build out of order.

{
    "executionStatus": {
        "/path/to/mydepb": {
            "status": "failure",
            "duration": 1804.710345,
            "error": {
                "code": "ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL",
                "errno": 2,
                "pkgid": "@mydep/b@",
                "stage": "build",
                "script": "standard build script",
                "pkgname": "@mydep/b",
                "prefix": "/path/to/mydepb"
            },
            "message": "@mydep/b@ build: `standard build script`\nExit status 2",
            "prefix": "/path/to/mydepb"
        },
        "/path/to/mydepa": {
            "status": "queued"
        }
    }
}

The monorepo builds correctly when done manually or with npm workspaces due to the folder order in the workspaces array.

Attempts like using --reverse=true or --resume-from=@mydep/a didn't impact the executionStatus at all.

Answer №1

Consider updating the reference

"@mydep/a": "link:../mydepb
in the package b package.json to
@mydep/a": "workspace:*"
.

This will transform the b package.json into:

{
   "name": "@mydep/b",
   "scripts": {
      "build": "standard build script"
   },
   "dependencies: {
      "@mydep/a": "workspace:*"
   }
}

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

Node-sass installation through NPM causing errors

I'm encountering difficulties installing node-sass in a project that builds and runs perfectly on my computer, but is causing major issues on my Surface when trying to install the packages. Note: I've attempted reinstalling and rebuilding the pr ...

Performing the npm run watch script within gradle

I am relatively new to gradle and npm, delving into the world of creating a grails3 - angularjs2 sample application. Here is the link to the application I am working on: https://github.com/agileorbit/grails3-angular2-starter However, when attempting to r ...

To install bower using npm, you can choose to use either -g or --save

As a beginner in node, I am currently discovering npm for working on node, angular, and Express tutorials. While following a previous tutorial, I utilized bower. After running the bower -v command and receiving back 1.3.3, I believe I have installed it glo ...

Building an NPM module specifically designed for Ionic app development requires a strategic approach

Currently, I am in the process of creating a library for Ionic 2 that needs to be installed via NPM. However, I am facing some challenges with the traditional installation method. When trying to develop a module, you can usually use the npm link command to ...

Problems during the installation of Webpack

Encountering Error Setting up Webpack and Babel with NPM npm ERR! Unexpected end of JSON input while parsing near '...pdragon":"^0.7.0","to' npm ERR! A complete log of this run can be found in: npm ERR! A complete log of this run can be found ...

Error Encountered: "fsevents is not defined" during ReactJS Test

I've been working on writing test cases for my program and I recently came across recommendations for testing-library/react and jest-junit. After installing both packages using npm as devDependencies and updating my test script to "test": 'react- ...

Having trouble with the installation of @ionic/cli-plugin-proxy version 1.3.0

When trying to download ionic/cli-plugin-proxy while behind a proxy server, I encountered the following error: npm install -g @ionic/cli-plugin-proxy npm ERR! code E500 npm ERR! 500 Internal Server Error: @ionic/cli-plugin-proxy@latest npm ERR! A complet ...

Caution: Be mindful when running npm install

Upon completing the npm installation process (version 4.1.2 on Windows 10) and running "npm install", a warning message popped up: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fseve ...

Having trouble installing Angular Material due to a getaddrinfo ENOTFOUND error?

When attempting to execute ng add @angular/material in my Angular project, I encountered the following error: Unable to fetch package metadata: request to http://registry.npmjs.org/@angular%2fmaterial failed, reason: getaddrinfo ENOTFOUND proxy.{companyna ...

What is the location of the storage for npm modules?

Currently, I am in the process of learning node.js and I have a couple of inquiries: Can you please explain where npm modules are stored? 2. Just to clarify, is node.js considered a database technology? 3. Lastly, do you need an internet connection in ...

What sets apart dependencies, devDependencies, and peerDependencies within an NPM package.json file?

I found this documentation to be inadequate in addressing my question. The explanations provided were difficult for me to grasp. Can someone please explain it more simply, perhaps with the help of examples if necessary? Additionally, I am also confused ab ...

What is the best way to execute the command "npm run watch" on a server for a Laravel project?

Seeking assistance with an issue I've encountered – I can't find the solution on my own. I am currently attempting to immediately update changes made in the code using "np m run watch", but I'm unsure how to do so on the server. All the f ...

I encountered an issue with the proxy configuration while working with Npm and Angular, specifically after installing and then uninstalling

Ever since I removed Fiddler, I've been encountering issues with using Angular and npm, specifically related to proxy errors. When attempting an http call with Angular, I receive the following error: [HPM] Error occurred while trying to proxy reque ...

How to globally install electron using NPM on Ubuntu

Encountering an issue while trying to resolve this problem. Upon installing electron globally using NPM, the following error is displayed: ole@mki:~/angular-electron$ sudo npm install electron -g /usr/bin/electron -> /usr/lib ...

Chokidar operates smoothly from the command line, but fails to function properly when invoked through the use of 'npm run'

I've implemented a script that monitors Tailwind CSS files using Chokidar. The script works perfectly when I execute the command in the CLI using chokidar 'tailwind.config.js' --initial=true -c 'npm run build-tailwind'. It successf ...

Using Browserify to load the npm-module client-side for thepiratebay

I am currently facing an issue with my node.js server file. It successfully loads my site and runs JavaScript, but I encountered a problem when trying to include tpb = require('thepiratebay'); in the server.js file. Although it works fine in the ...

Connecting JSON objects based on unique GUID values generated

I am in search of a method to automate the laborious task of linking multiple JSON objects with random GUIDs. The JSON files are all interconnected: { "name": "some.interesting.name", "description": "helpful desc ...

What is the reason behind the restriction on using capital letters in React project names?

When attempting to create a new project "newRecipeApp" in React, I encountered the following message: npx: installed 91 in 29.359s Could not create a project called "newRecipeApp" because of npm naming restrictions: * name can no longer contain capital ...

Guide on implementing ES6 script's template literals

I've been tackling a template literal question on hackerrank. It's working smoothly on my local IDE, but encountering an error on the Hackerrank IDE. Here's the code to add two numbers and print the result using a template literal: const sum ...

Utilizing Node.js, Express, Jade, and Templates within a single package

Can templates for an express application be stored in a separate package? In my scenario, I am interested in having a shared package that contains global templates to ensure all apps have a consistent look and feel, even if they are running independently ...