问题描述
我不小心将 npm 前缀更改为不存在的地方.是否有我可以访问的配置文件允许我将其更改回来?
I accidentally changed the npm prefix to a place that doesn't exist. Is there a configuration file I can access that would allow me to change this back?
我能想到的唯一选择是:
The only options I can think of are:
- 完全卸载节点(更改前缀后npm没有响应)
- 我想我可以创建不存在的目录并将 npm 文件移到那里.
但似乎应该有一个我可以在某处更改的配置文件,对吗?
But it seems like there should be a config file I can change somewhere, right?
推荐答案
prefix
可以使用 --prefix
定义每个安装和其他命令,但作为全局设置它在 ~/.npmrc
(C:\Users\\.npmrc
).您可以直接在该文件中删除/编辑它.
prefix
can be defined per-install and other commands using --prefix
, but as a global setting it is in ~/.npmrc
(C:\Users\<your user name>\.npmrc
). You can remove / edit it directly in that file.
如果你愿意,你也可以使用 npm config set prefix $value
,或者 npm config delete prefix
.
You can also use npm config set prefix $value
, or npm config delete prefix
if you prefer.
这篇关于如何在没有配置的情况下更改 npm 前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!