Skip to content

[BUG] workspace scripts should be run in topological order by default #4139

@justinfagnani

Description

@justinfagnani

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

when running a script across workspaces like npm run build --workspaces you'll most likely end up with errors if your workspaces depend on each other as npm doesn't execute the script in topological order. Other monorepo tools like Lerna do this automatically.

The only workaround is to not use "workspaces": ["packages/*"] in package.json, but manually enter and maintain the list of packages by hand.

Expected Behavior

Scripts should run in topological order.

Steps To Reproduce

  1. In any environment...
  2. With a config that has multiple workspaces and wildcard workspaces setting like "workspaces": ["packages/*"], and one package that depends on another, and say both use TypeScript...
  3. Run npm run build --workspaces
  4. See error from the compiler

Environment

  • npm: 8.2.0
  • Node: 16.9.1
  • OS: macOS 12.0.1
  • platform: macOS
  • npm config:
legacy-peer-deps = true 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancementnew feature or improvementPriority 2secondary priority issueRelease 8.xwork is associated with a specific npm 8 releaseconfig:workspacerelated to `--workspace`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions