Skip to content
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

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

Closed
1 task done
nikolaik opened this issue Aug 20, 2021 · 2 comments · Fixed by #4777
Closed
1 task done

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

nikolaik opened this issue Aug 20, 2021 · 2 comments · Fixed by #4777
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@nikolaik
Copy link

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
@nikolaik nikolaik added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Aug 20, 2021
@wraithgar wraithgar added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Mar 16, 2022
@nlf
Copy link
Contributor

nlf commented Apr 11, 2022

#4643 fixes this issue /cc @ruyadorno

ruyadorno added a commit to ruyadorno/cli that referenced this issue Apr 19, 2022
Refactor / clean up of the logic around reading installed
packages. Fixes reading packages from mixed sources (one being
from the local installed tree and the other from the registry
using pacote.manifest).

Makes it so that libnpmexec is always reading from the
Arborist actual tree instead of reading `node_modules` from
the file system when retrieving local package data.

Fixes: npm#3668
Relates to: npm#4643
Relates to: npm#4619
Relates to: npm/statusboard#403
@ruyadorno
Copy link
Contributor

moved the bit that fixes this issue to #4777

lukekarrys pushed a commit that referenced this issue Apr 19, 2022
Refactor / clean up of the logic around reading installed
packages. Fixes reading packages from mixed sources (one being
from the local installed tree and the other from the registry
using pacote.manifest).

Makes it so that libnpmexec is always reading from the
Arborist actual tree instead of reading `node_modules` from
the file system when retrieving local package data.

Fixes: #3668
Relates to: #4643
Relates to: #4619
Relates to: npm/statusboard#403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants