当前位置:网站首页>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
, --local
Deprecated Removed,Ask to use instead--location=global
2.npm WARN logfile
The 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>
边栏推荐
- 后台管理系统的权限思路
- el-form-item prop属性动态绑定不生效如何解决
- MySQL Lock wait timeout exceeded; try restarting transaction 锁等待
- 食品安全 | 新鲜食品vs速食食品,哪一种是你的菜?
- B005 - STC8 based single chip microcomputer intelligent street light control system
- MySQL关系型数据库事务的ACID特性与实现方法
- QLineEdit learning and use
- golang json 返回空值
- 7月30号|来一场手把手助您打造智能视觉新爆款的技术动手实验
- QT_QDialog dialog
猜你喜欢
随机推荐
QT_QThread线程
Golang协程调度器scheduler怎么使用
成都理工大学&电子科技大学|用于强化学习的域自适应状态表示对齐
【翻译】CNCF培养的OpenMetrics成为一个孵化项目
Zabbix6.0钉钉机器人告警
opencv基本的图像处理
塔防海岸线用户协议
EpiSci | Deep Reinforcement Learning for SoCs: Myth and Reality
What is the JVM runtime data area and the JMM memory model
B002 - Embedded Elderly Positioning Tracking Monitor
Go GORM事务实例分析
极化微波成像概述2
How to solve the dynamic binding of el-form-item prop attribute does not take effect
阿里云的域名和ip绑定
极化微波成像概述
B011 - 基于51的多功能指纹智能锁
Leetcode73. 矩阵置零
打开微信客服
【Day_09 0427】 另类加法
将ENS域名转化为音乐需要几步?