Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install not installing things at /usr/bin

I am trying to install SailsJS with:

$ sudo npm install -g sails

It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails with the following log:

/home/brunoluiz/npm/bin/sails -> /home/brunoluiz/npm/lib/node_modules/sails/bin/sails.js
[email protected] /home/brunoluiz/npm/lib/node_modules/sails
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

The problem is when you try to use sails: you run sails new project, for example, and it doesn't find sails. Investigating a little bit, I discovered npm is not installing the modules at /usr/bin. Is there some reason for that? Some config?

The same is happening with Karma module.

I used the nodejs from ppa, created the symbolic link for node and installed npm from the official install.sh script (https://www.npmjs.org/install.sh).

like image 828
Bruno Luiz Avatar asked Nov 30 '22 11:11

Bruno Luiz


1 Answers

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.

like image 171
mklement0 Avatar answered Dec 02 '22 02:12

mklement0