Skip to content

[BUG] OS specific module breaks workspace installation #6138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
MondoGao opened this issue Feb 7, 2023 · 6 comments
Open
2 tasks done

[BUG] OS specific module breaks workspace installation #6138

MondoGao opened this issue Feb 7, 2023 · 6 comments
Labels
config:workspace related to `--workspace` Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release ws:arborist Related to the arborist workspace

Comments

@MondoGao
Copy link

MondoGao commented Feb 7, 2023

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 workspace config contains a package that requests an specific os/cpu, if current platform doesn't match that requirement, npm will panic and throw 'EBADPLATFORM' error.

Currently we can't mark a workspace package "optional" in any ways. In order to finish the installation process, we need to use "--force" flag.

Packages that need to build sub n-api platform-specific packages like esbuild face this issue.

Expected Behavior

Let npm have a config to consider a workspace package "optional".

One method to archive that is using optionalDependencies config:

# root pacage.json
{
  "workspaces": ["a"],
  "optionalDependencies": {
    "a": "*"
  }
}

Or add another config like the peerDependenciesMeta:

# root pacage.json
{
  "workspaces": ["a"],
  "workspacesMeta": {
    "a": {
      "optional": true
    }
  }
}

Steps To Reproduce

For example:

# root pacage.json
{
  "workspaces": ["a"]
}
# a/package.json
{
  "name": "a",
  "os": [
    "darwin"
  ],
  "cpu": [
    "x64"
  ]
}

When trying to run npm install on an different platform, error like below will be thrown:
CleanShot 2023-02-07 at 10 12 55

Environment

  • npm: 9.4.0
  • Node.js: 16.18.1
  • OS Name: MacOS 13.0.1
  • System Model Name: Macbook Pro 16'
  • npm config: unrelated
@MondoGao MondoGao added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Feb 7, 2023
@MondoGao
Copy link
Author

MondoGao commented Feb 7, 2023

Related issue in yarn 1: yarnpkg/yarn#5951

@DevCon1100
Copy link

Access

1 similar comment
@DevCon1100
Copy link

Access

@fritzy fritzy added ws:arborist Related to the arborist workspace config:workspace related to `--workspace` Priority 2 secondary priority issue and removed Needs Triage needs review for next steps Bug thing that needs fixing labels Mar 1, 2023
@fritzy
Copy link
Contributor

fritzy commented Mar 1, 2023

This isn't really a bug, so it probably be in the npm/rfcs repo, but it also feels like an oversight. We should probably do this.

@kasperisager
Copy link

I just hit this as well with a monorepo that contains OS and architecture specific packages. As a user of npm, it definitely feels like a bug and renders the workspace feature unusable for such monorepos.

@loozhengyuan
Copy link

Just encountered the same issue as well and it really does make the workspace rather unusable. It also feels quite hacky having to use --force to bypass this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config:workspace related to `--workspace` Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release ws:arborist Related to the arborist workspace
Projects
None yet
Development

No branches or pull requests

5 participants