Skip to content

[BUG] npx crashes when mixing implicit/explicit modules in -p #3668

Description

@nikolaik

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Run the following npx command in a directory that has an existing node_modules with one of the modules already installed. When mixing implict and specific like below, npx crashes when it tries to tread undefined as a string.

$ npx -p [email protected] -p @babel/core gitmoji -l
npm ERR! Cannot read property 'replace' of undefined

Here is the stack trace from the debug log:

32 verbose stack TypeError: Cannot read property 'replace' of undefined
32 verbose stack     at .nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:163:47
32 verbose stack     at Array.map (<anonymous>)
32 verbose stack     at exec (.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:163:31)

Not sure if it crashes because of the missing version specifier @babel/core when it already has a fixed version in package.json or something else.

Expected Behavior

Expect it to prompt for installation (the first time it is run):

$ npx -p [email protected] -p @babel/core@7 gitmoji -l
Need to install the following packages:
  @babel/core@7
  [email protected]
Ok to proceed? (y) 

Steps To Reproduce

# create a new dir with an empty package.json
mkdir fresh-dir && cd fresh-dir && npm init -y
npm i @babel/core
npx -p [email protected] -p @babel/core gitmoji -l

Environment

  • OS: Ubuntu 21.04
  • Node: 14.16.0
  • npm: 7.21.0

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