当前位置:网站首页>Three solutions: npm WARN config global --global, --local are deprecated. Use --location=global instead.
Three solutions: npm WARN config global --global, --local are deprecated. Use --location=global instead.
2022-08-01 18:11:00 【丨Jack_Chen丨】
场景
After replacing the computer hard drive,Reinstall the development software.当安装node后进行验证,执行npmcommand alert:
PS C:\Windows\system32> npm install --g xxx
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN logfile could not create logs-dir: Error: EPERM: operation not permitted, mkdir 'D:\Development\nodejs\node_cache\_logs'
原因
1.--global, --localDeprecated Removed,Ask to use instead--location=global
2.npm WARN logfileThe warning is because the corresponding directory does not have permission,Right-click to open the directory properties and give all permissions
解决方案
方案一
找到nodejs安装目录
Edit the four namednpm, npm.cmd, npx,npx.cmd的文件
在文件中替换prefix -g为prefix --location=global
Admin rights are saved
以npm文件为例
方案二
This warning is officialnpm 8.12.1中得到了修复,So you can upgrade the installationnpm
# 安装最新版
npm install -g npm@latest
# 安装指定版本
npm install -g npm@8.12.1
也可以降级npm
# 安装指定版本
npm install -g npm@8.12.1
方案三(重点)
This program is the focus program,I used this solution to solve the problem
以管理员身份运行 PowerShell,执行如下命令
# 修改策略
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install --global --production npm-windows-upgrade
npm-windows-upgrade 或 npm-windows-upgrade --npm-path "node安装路径"
# Restore the original strategy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
日志如下
1.在执行npm-windows-upgrade命令报错
2.So try to enter its installation directory,The result is still an error
3.Use after reading the tips./The method explicitly specifies that the execution succeeds after the command is executed
4.Select after successful executionnpm版本,然后执行npm -v命令测试,发现警告消失
5.Finally revert to the original system policy
PS C:\Windows\system32> Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
PS C:\Windows\system32> npm install --global --production npm-windows-upgrade
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN config production Use `--omit=dev` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
changed 50 packages in 5s
PS C:\Windows\system32> npm-windows-upgrade
npm-windows-upgrade : 无法将“npm-windows-upgrade”项识别为 cmdlet、函数、脚本文件或可运行程序的名称.请检查名称的拼写
,如果包括路径,请确保路径正确,然后再试一次.
所在位置 行:1 字符: 1
+ npm-windows-upgrade
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (npm-windows-upgrade:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS D:\Development\nodejs\node_global> npm-windows-upgrade --npm-path "D:\Development\nodejs"
npm-windows-upgrade : 无法将“npm-windows-upgrade”项识别为 cmdlet、函数、脚本文件或可运行程序的名称.请检查名称的拼写
,如果包括路径,请确保路径正确,然后再试一次.
所在位置 行:1 字符: 1
+ npm-windows-upgrade --npm-path "D:\Development\nodejs"
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (npm-windows-upgrade:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: 找不到命令 npm-windows-upgrade,但它确实存在于当前位置.默认情况下,Windows PowerShell will not follow Front position load command.如果信任此命令,请改为键入“.\npm-windows-upgrade”.有关详细信息,请参阅 "get-help about_Command_Precedence".
PS D:\Development\nodejs\node_global> ./npm-windows-upgrade --npm-path "D:\Development\nodejs"
npm-windows-upgrade v6.0.1
? Which version do you want to install? 8.15.0
Given path D:\Development\nodejs is a valid directory. Upgrading npm... |
Upgrading npm (fallback method)... \
Upgrade finished. Your new npm version is 8.15.0. Have a nice day!
PS D:\Development\nodejs\node_global> npm -v
8.15.0
PS D:\Development\nodejs\node_global> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
PS D:\Development\nodejs\node_global>
边栏推荐
- [供应链·案例篇]石油和天然气行业的数字化转型用例
- 【Translation】OpenMetrics cultivated by CNCF becomes an incubation project
- Stop using MySQL online DDL
- University of California | Inverse Reinforcement Learning from Different Third-Person Videos via Graph Abstraction
- Detailed explanation of DBPack SQL Tracing function and data encryption function
- 公用函数----mfc
- tooltip 控件
- Go GORM transaction instance analysis
- 移动端吸顶方案
- Topology Parts Disassembly 3D Visualization Solution
猜你喜欢

el-form-item prop属性动态绑定不生效如何解决

食品安全 | 新鲜食品vs速食食品,哪一种是你的菜?
Detailed explanation of DBPack SQL Tracing function and data encryption function

SRM供应商管理系统如何助力口腔护理企业实现采购战略的转型升级

Topology Parts Disassembly 3D Visualization Solution

Topology零部件拆解3D可视化解决方案

【Day_09 0427】 另类加法

移动端吸顶方案

QT basic functions, signals, slots

QT_QThread线程
随机推荐
The function realization of the national standard GB28181 protocol EasyGBS platform compatible with the old version of the inflow port
Detailed explanation of DBPack SQL Tracing function and data encryption function
QT commonly used global macro definitions
【Day_10 0428】井字棋
三维空间中点的插值
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) Solution
EpiSci|片上系统的深度强化学习:神话与现实
C#/VB.NET:从 PDF 文档中提取所有表格
opencv syntax Mat type summary
Leetcode72. 编辑距离
想随时、随地、随心使用数据库的朋友们,全体注意!
el-form-item prop属性动态绑定不生效如何解决
Leetcode75. Color Classification
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) 题解
Leetcode71. Simplified Paths
中信证券是国内十大券商吗?怎么开户安全?
【Day_11 0506】求最大连续bit数
golang json 返回空值
2022年MySQL最新面试题
深入浅出Flask PIN