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

fix: Fix npm install --prefix on windows #7725

Open
wants to merge 1 commit into
base: latest
Choose a base branch
from

Commits on Aug 15, 2024

  1. fix: Fix npm install --prefix on windows

    I found that globalDir/localDir and globalPrefix/localPrefix
    end up being the same value when `--prefix` is set. This was
    surprising to me, but it does appear that `globalPrefix` is set
    to match `prefix` at the end of loading.
    
    This means that the globalTop logic is actually incorrect here.
    It accidentally worked on non-windows machines.
    
    For example if running `npm i --prefix scripts`
    
    On non-windows
    this.npm.globalDir = $CWD/scripts/lib/node_modules
    
    On windows
    this.npm.globalDir = $CWD/scripts/node_modules
    
    IMHO, the logic inside of npmconfig is also incorrect here, since
    globalDir is being set to this bogus `$CWD/scripts/lib/node_modules`
    
    However, this fix should work regardless - since it stops relying
    on the specific values of globalDir.
    
    Fixes npm#7722
    
    I manually tested `npm install` and `npm install --prefix` on both
    windows and mac. Everything works now.
    nipunn1313 committed Aug 15, 2024
    Configuration menu
    Copy the full SHA
    eee038d View commit details
    Browse the repository at this point in the history