Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
619 views
in Technique[技术] by (71.8m points)

node.js - 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).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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}in location.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...