You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] --location=global does not work from package.json scripts #4945
I noticed the deprecation warning for --global and changed over to --location=global. However I found that this doesn't work from scripts in package.json. The parameter seems to be silently ignored, whereas --global works and with no deprecation warning. The same thing happens with --location global, -L=global and -L global, all of which work outside package.json scripts.
Expected Behavior
--location=global (and other notations) should work from package.json scripts. I would also expect the deprecation warning to be printed for --global.
Steps To Reproduce
From a fresh npm project (npm init -y).
Set the package.json "test" script to npm install --location=global stylelint.
Run npm run test.
Note that stylelint is installed locally and added as a dependency in package.json.
--location=global is a bit long to type out each time on the command line. IMHO, would be an improvement if some shorter mnemonic could be added, like -g or something...
Reacted by Matt Mower, André Milani, Joel Pittet, Guilherme Higashi, tja4472, Sergei, jeffrson, Logan, i0air and José Vitor Andrade
--location=global is a bit long to type out each time on the command line. IMHO, would be an improvement if some shorter mnemonic could be added, like -g or something...
Confusingly, this does appear to work on a different Windows PC. Same version of Windows, same version of node, same version of npm, same (default) config, same terminal (cmd.exe), so I don't know what could be causing it...
By the way I agree that there should be at least -L=g in addition to -L=global (and I don't really understand the purpose of deprecating -g), but I think that discussion is beyond the scope of this bug.
Issue #4989 makes me wonder if this bug is the result of the seemingly indirect way that npm is invoked on Windows.
In that issue, we see that some module bundled with node v16.15.1 is causing the deprecation warning on every invocation of npm, even versions of npm in which --global is not deprecated (like version 8.12.1).
In this issue, perhaps the problem is that node v16.15.0 includes an older version of this module which doesn't have support for --location and ends up stripping it out before passing the parameters to npm.
I figured out the cause of this: I somehow had another version of npm installed at %UserProfile%! It seems that npm run used this version instead of the version in %AppData%\npm.
Activity
ehoogeveen-medweb commentedon May 26, 2022
This issue may be specific to Windows - on Linux I do see the deprecation warning and the dependency is installed globally as expected.
kenbanks-peng commentedon May 27, 2022
--location=global is a bit long to type out each time on the command line. IMHO, would be an improvement if some shorter mnemonic could be added, like -g or something...
andmm commentedon May 29, 2022
Yeah... like it used to be.
ehoogeveen-medweb commentedon May 30, 2022
Confusingly, this does appear to work on a different Windows PC. Same version of Windows, same version of node, same version of npm, same (default) config, same terminal (cmd.exe), so I don't know what could be causing it...
By the way I agree that there should be at least
-L=gin addition to-L=global(and I don't really understand the purpose of deprecating-g), but I think that discussion is beyond the scope of this bug.ehoogeveen-medweb commentedon Jun 3, 2022
Issue #4989 makes me wonder if this bug is the result of the seemingly indirect way that
npmis invoked on Windows.In that issue, we see that some module bundled with node
v16.15.1is causing the deprecation warning on every invocation ofnpm, even versions ofnpmin which--globalis not deprecated (like version8.12.1).In this issue, perhaps the problem is that node
v16.15.0includes an older version of this module which doesn't have support for--locationand ends up stripping it out before passing the parameters tonpm.ehoogeveen-medweb commentedon Jun 5, 2022
I figured out the cause of this: I somehow had another version of npm installed at
%UserProfile%! It seems thatnpm runused this version instead of the version in%AppData%\npm.