npm:如何重置 node_modules 前缀

npm: How to reset the node_modules prefix

我通过自制软件安装了节点。 由于我在访问包时遇到问题,我尝试将 node_modules 前缀更改为 user/local 但在键入命令时出错:

npm config set prefix /usr/l    # See the typo there
                            ^

现在,每当我 运行 一个 npm 命令时,我都会收到以下错误:

$ npm config ls -l
Error: EACCES: permission denied, mkdir '/usr/l'
at Error (native)

i cannot set the prefix again (npm config set prefix /usr/local) , or even list the config ( npm config ls -l ) – 都会产生与上述相同的错误。我尝试重新安装 node/npm.

如何重置前缀?谢谢。

如果是权限错误,你应该可以使用 sudo 来 运行 它作为 root。这应该解决权限问题,它似乎在错误消息中