简体   繁体   English

"如何在没有配置的情况下更改 npm 前缀?"

[英]How to change the npm prefix without config?

I accidentally changed the npm prefix to a place that doesn't exist.我不小心将 npm 前缀更改为一个不存在的地方。 Is there a configuration file I can access that would allow me to change this back?有没有我可以访问的配置文件可以让我改回来?

The only options I can think of are:我能想到的唯一选择是:

  1. Completely Uninstall Node ( npm not responding after changing the prefix<\/a> )完全卸载节点( 更改前缀后 npm 没有响应<\/a>)<\/li>
  2. I guess I could create the directories that don't exist and move the npm files there.我想我可以创建不存在的目录并将 npm 文件移到那里。<\/li><\/ol>

    But it seems like there should be a config file I can change somewhere, right?但似乎应该有一个配置文件我可以在某处更改,对吧?

    "

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 ). prefix可以使用--prefix在每次安装和其他命令中定义,但作为全局设置,它位于~/.npmrcC:\\Users\\<your user name>\\.npmrc )中。 You can remove / edit it directly in that file. 您可以直接在该文件中删除/编辑它。

You can also use npm config set prefix $value , or npm config delete prefix if you prefer. 您也可以根据需要使用npm config set prefix $valuenpm config delete prefix

一个简单的ln -s \/usr\/local\/bin\/n \/usr\/bin\/n<\/code>已经解决了这个问题。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM