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] npm.cmd uses deprecated switch -g #4980

Closed
2 tasks done
flensrocker opened this issue Jun 2, 2022 · 76 comments
Closed
2 tasks done

[BUG] npm.cmd uses deprecated switch -g #4980

flensrocker opened this issue Jun 2, 2022 · 76 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@flensrocker
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When invoking npm --version on Windows there is a warning about a deprecated commandline switch:

❯ npm --version
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.12.0

Expected Behavior

No warning when no deprecated switch is used.

Steps To Reproduce

After upgrading npm to version 8.12.0 with npm-windows-upgrade npm always shows a warning on every execution about the deprecated switch -g.

Environment

  • npm: 8.12.0
  • Node.js: 16.15.0
  • OS Name: Windows 11
@flensrocker flensrocker added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jun 2, 2022
@AlttiRi
Copy link

AlttiRi commented Jun 2, 2022

Same with npm 8.11.0 after installing Node.js v18.3.0. (Node.js v18.2.0 does not have this problem.)
Using of npx also shows the warning.

@nlf
Copy link
Contributor

nlf commented Jun 2, 2022

we've reverted this deprecation in v8.12.1, so i'm closing this issue. thanks for the reports!

@nlf nlf closed this as completed Jun 2, 2022
@yury-tyshkevich
Copy link

Not solved!

PowerShell

PS C:\> npm -v
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.12.1 👈
PS C:\>

@adazmy
Copy link

adazmy commented Jun 2, 2022

Issue still there on 8.12.1

npm -v
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.12.1

It is solved by editing C:\Program Files\nodejs\npm.cmd
on line 12
replacing prefix -g by prefix --location=global

@GitSkelly
Copy link

Is there a way to re-open this issue or will updates keep coming through this feed?

I too am having this issue still on 8.12.1.

@weezyade
Copy link

weezyade commented Jun 2, 2022

I'm having the same issue......on both versions

@Dany-GP
Copy link

Dany-GP commented Jun 3, 2022

Hi there, I had the same issue, this command solve the bug for me
npm-windows-upgrade --npm-version latest
You have to run your powershell or cmd as administrator

@Gino16
Copy link

Gino16 commented Jun 3, 2022

Issue is still here in npm 8.12.1 version:

$ npm -v
npm WARN config global --global, --local are deprecated. Use --location=global instead.
8.12.1 👀

@Dany-GP
Copy link

Dany-GP commented Jun 3, 2022

Did you opened command prompt as Administrator? What OS are you running npm? @Gino16

@Gino16
Copy link

Gino16 commented Jun 3, 2022

I used Git Bash, my OS is Windows 10, its the same result when I open in cmd as Administrator @Dany-GP

@Dany-GP
Copy link

Dany-GP commented Jun 3, 2022

you can try to set the commands that come here
npm install --global --production npm-windows-upgrade
Running this command as admin command prompt should resolve this issue. I recommend you try on administrator cmd.

@flensrocker
Copy link
Author

Running npm-windows-upgrade as administrator and upgrading to 8.12.1 fixed my problem.

Thank you, @nlf !

@denvolch
Copy link

denvolch commented Jun 3, 2022

Проблема все еще существует на 8.12.1

npm -v
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.12.1

Решается правкой C:\Program Files\nodejs\npm.cmd в строке 12 замена prefix -gпо prefix --location=global

thx a lot

@weezyade
Copy link

weezyade commented Jun 3, 2022

can't find the lastest npm upgrade, need help.

@flensrocker
Copy link
Author

@weezyade
If you are on Windows, run in an Administrator prompt:

npm install -g npm-windows-upgrade
npm-windows-upgrade

and select version 8.12.1 for installation.

@Hashsudo
Copy link

Hashsudo commented Jun 3, 2022

I was able to resolve using the steps mentioned. I'll provide screenshots in the event others experience issues similar to mine using Powershell admin. Much appreciated flensrocker! Hope this helps others.

Step 1:
Screenshot_2

Step 2:
Screenshot_3

Step 3:
Screenshot_4

Step 4:
Screenshot_5
png)

@NSExceptional
Copy link

@nlf this is clearly not resolved, can we reopen it?

@Hashsudo
Copy link

Hashsudo commented Jun 3, 2022

@nlf this is clearly not resolved, can we reopen it?

I agree. The issue is not resolved. There is a workaround, but it shouldn't be necessary if a true resolution was found

@flensrocker
Copy link
Author

@NSExceptional @Hashsudo
Why is this not resolved for you? It's a bug in versions <= 8.12.0 and fixed in 8.12.1.

@Hashsudo
Copy link

Hashsudo commented Jun 3, 2022

@NSExceptional @Hashsudo Why is this not resolved for you? It's a bug in versions <= 8.12.0 and fixed in 8.12.1.

I understand. I believe that the reference is to the installer. It will not update via the installer and requires manual alterations via Powershell. That's what I meant anyway. I do agree though that it is resolved in the sense that following the steps in Powershell correct the issue.

@NSExceptional
Copy link

There are a half dozen comments here all saying the same thing: it was not fixed in 8.12.1. Just experienced this myself.

@Hashsudo
Copy link

Hashsudo commented Jun 3, 2022

There are a half dozen comments here all saying the same thing: it was not fixed in 8.12.1. Just experienced this myself.

I believe that many people are doing what I was initially by uninstalling and reinstalling via the installer trying to update. It will not update that way. Still, the Powerhsell steps do fix the issue. So, in that sense, 8.12.1 is a fix.

@flensrocker
Copy link
Author

flensrocker commented Jun 10, 2022

This does not look right. Please try only the Set-ExecutionPolicy command with the parameters.
If this succeeds, then try npm-windows-upgrade command.

@Fredrik2
Copy link

Set-ExecutionPolicy

All right, I think I need to wait for my teachers help, I belive if I can talk to him he may understand what you are saying. this is greek for me, im really thankful for your help.

@NurulloSalaydinov
Copy link

Issue still there on 8.12.1

npm -v
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.12.1

It is solved by editing C:\Program Files\nodejs\npm.cmd on line 12 replacing prefix -g by prefix --location=global

Firstly it didn't work at me but in that time i didn't save it 😅🤦‍♂️

@Leandro-FM
Copy link

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
npm install -g npm-windows-upgrade
npm-windows-upgrade

@Leandro-FM
Copy link

OK! ok!.. UHUHUHUHHUH.. Obrigado!

@Leandro-FM
Copy link

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
npm install -g npm-windows-upgrade
npm-windows-upgrade

// Resolvido
PS C:\WINDOWS\system32> 8.12.1
PS C:\WINDOWS\system32> PS C:\WINDOWS\system32>^C
PS C:\WINDOWS\system32> 8.12.1
PS C:\WINDOWS\system32> npm -v
8.12.1
PS C:\WINDOWS\system32>

@ashifbabu
Copy link

It is solved by editing C:\Program Files\nodejs\npm.cmd
on line 12
replacing prefix -g by prefix --location=global

It works ;)

It works for me too

Finally works 👍 :) Thanks

@IMDanijel
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When invoking npm --version on Windows there is a warning about a deprecated commandline switch:

❯ npm --version
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.12.0

Expected Behavior

No warning when no deprecated switch is used.

Steps To Reproduce

After upgrading npm to version 8.12.0 with npm-windows-upgrade npm always shows a warning on every execution about the deprecated switch -g.

Environment

  • npm: 8.12.0
  • Node.js: 16.15.0
  • OS Name: Windows 11

**This worked for me,
Run CMD as Administrator:

C:/WINDOWS/system32>npm-windows-upgrade --npm-version latest
npm-windows-upgrade v6.0.1
Checked system for npm installation:
According to PowerShell: C:\Program Files\nodejs
According to npm: C:\Users\Admin\AppData\Roaming\npm
Decided that npm is installed in C:\Program Files\nodejs
Upgrading npm.../

Upgrading npm (fallback method)... |

Upgrade finished. Your new npm version is 8.12.2. Have a nice day!

C:\WINDOWS\system32>npm -v
8.12.2

@arantisi
Copy link

arantisi commented Jul 2, 2022

im having this issue as well what do i do ?
image

@flensrocker
Copy link
Author

As Administrator run

npm i -g npm-windows-upgrade
npm-windows-upgrade

@yangjunran
Copy link

1657120836624

@woorykim
Copy link

  1. npm i -g npm-windows-upgrade
  2. npm-windows-upgrade
  3. If the above problem persists, use the following methods:
    (feat. @Hashsudo - Thanks! UHUH~~~~ Thank for you solve!🧙‍♂️)

언급된 단계를 사용하여 해결할 수 있었습니다. 다른 사람들이 Powershell 관리자를 사용하여 나와 유사한 문제를 경험하는 경우 스크린샷을 제공하겠습니다. 대단히 감사하는 flensrocker! 이것이 다른 사람들을 돕기를 바랍니다.

1 단계: 스크린샷_2

2 단계: 스크린샷_3

3단계: 스크린샷_4

4단계: png) 스크린샷_5

@snebjorn
Copy link

snebjorn commented Oct 12, 2022

PS> npm --version
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.19.2


PS> node -v
v16.16.0


PS> Get-Command npm

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     npm.cmd                                            0.0.0.0    C:\Program Files\nodejs\npm.cmd


PS> Get-ComputerInfo OsName,OsVersion,OsBuildNumber,OsHardwareAbstractionLayer,WindowsVersion

OsName                     : Microsoft Windows 11 Enterprise
OsVersion                  : 10.0.22000
OsBuildNumber              : 22000
OsHardwareAbstractionLayer : 10.0.22000.778
WindowsVersion             : 2009

Is the official fix for this error to run the following?

npm i -g npm-windows-upgrade
npm-windows-upgrade

Or will this be fixed in via an update? So we can just run npm i -g npm

@flensrocker
Copy link
Author

@snebjorn As I understand the installation of npm on Windows, npm i -g npm will never work, see the official documentation.

npm-windows-upgrade is the way to go.

@HucklJS
Copy link

HucklJS commented Dec 11, 2022

I just upgraded npm by opening C:\Program Files\nodejs as administrator in PowerShell and running npm install npm. No more warnings during version check.

raineorshine added a commit to raineorshine/npm-check-updates that referenced this issue Sep 13, 2023
--global was erroneously deprecated in node v16.15.1 and npm v8.12.0 on Windows.

npm/cli#4980
npm/cli#4982
raineorshine added a commit to raineorshine/npm-check-updates that referenced this issue Nov 3, 2023
--global was erroneously deprecated in node v16.15.1 and npm v8.12.0 on Windows.

npm/cli#4980
npm/cli#4982
raineorshine added a commit to raineorshine/npm-check-updates that referenced this issue Nov 5, 2023
--global was erroneously deprecated in node v16.15.1 and npm v8.12.0 on Windows.

npm/cli#4980
npm/cli#4982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.