npm install not installing things at /usr/bin

余生长醉 提交于 2019-11-29 07:46:39

It sounds like your npm installation is configured to use /home/brunoluiz/npm as prefix, meaning that it will place symlinks to the CLIs that come with globally installed packages in {prefix}/bin.

In a default installation, prefix is either /usr or /usr/local on Unix platforms (%APPDATA%/npm on Windows).

If {prefix}/bin is not in your $PATH, you won't be able to execute such CLIs just by name.

To see the current prefix value in effect, run:

npm get prefix

Your options are:

  • Add /home/brunoluiz/npm/bin to your $PATH

  • Change the value of the prefix configuration item to a folder whose bin subfolder is already in your $PATH; e.g.:

    npm set prefix /usr       # Ubuntu; CLI symlinks are placed in /usr/bin
    npm set prefix /usr/local # OSX; CLIs symlinks are placed in /usr/local/bin

Note, however, that you'd then have to reinstall your global packages for the symlinks to be created in the new {prefix}\bin location.

In addition to mklement0's answer, the first solution (adding the npm binary directory path to the PATH variable) creates another problem when the commands are run with sudo prefix on Linux environment. To solve it, the npm binary directory path must also be added in secure_path in /etc/sudoers.tmp. Here is how: Why can't sudo find a command after I added it to PATH?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!