Skip to content

[BUG] npx/npm exec don't work in child workspace when using --no/--no-install and --package #3520

Description

@rossng

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I am using NPM workspaces. I am running a command of the format:

npm exec --no --workspace=my-workspace --package @graphql-codegen/cli -- graphql-codegen --config codegen.js

It fails with a rather terse npm ERR! canceled.

This is related to a previous issue #2826. The bug was partially resolved by @ruyadorno in npm/libnpmexec#2. However, looking at the commit, it seems that the fix was only applied inside the if (needPackageCommandSwap) block. This only executes if no --package option has been specified.

If --package is specified, then the code falls through to https://github.com/npm/libnpmexec/blob/a9423e441b914571ec18ad8a4496a3ecf2f500e2/lib/index.js#L153. It will then try to install the package (even though it's already available locally). However, if --no[-install] is specified, it will simply throw an exception instead.

Expected Behavior

The npm exec and npx commands should work when used in a workspace with the --package and --no[-install] options.

Steps To Reproduce

No response

Environment

  • OS: Windows
  • Node: 16.4.0
  • npm: 7.19.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 1high priority issueRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions