npm install not installing things at /usr/bin

前端 未结 2 1098
天涯浪人
天涯浪人 2020-12-18 08:39

I am trying to install SailsJS with:

$ sudo npm install -g sails

It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails

2条回答
  •  长情又很酷
    2020-12-18 08:55

    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.

提交回复
热议问题