2014-04-15 57 views
3

安裝的事情,我想安裝與SailsJS:NPM安裝不是在/ usr/bin中

$ sudo npm install -g sails 

它的工作原理,通過/ home/brunoluiz/NPM與以下日誌安裝一切/ lib目錄/ node_modules /帆:

/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]) 

問題是,當您嘗試使用帆:在運行sails new project,例如,它沒有找到帆。稍微調查一下,我發現npm並沒有在/ usr/bin下安裝模塊。這有什麼理由嗎?一些配置?

Karma模塊也是如此。

我使用了ppa中的nodejs,創建了節點的符號鏈接,並從官方install.sh腳本(https://www.npmjs.org/install.sh)安裝了npm。

回答

8

這聽起來像你npm安裝配置爲使用/home/brunoluiz/npmprefix,這意味着它將會把符號連接,在{prefix}/bin來在全球安裝的軟件包的CLI。

在默認安裝中,prefix是Unix平臺上的/usr/usr/local(Windows上的%APPDATA%/npm)。

如果{prefix}/bin不在您的$PATH中,您將無法按名稱執行此類CLI。

要查看當前有效的prefix值,運行:

npm get prefix 

的選項有:

  • 添加/home/brunoluiz/npm/bin$PATH

  • 更改值prefix配置項目到bin子文件夾已在您的0文件夾中;例如: -

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 

注意,但是,你則需要重新安裝的全球包在新{prefix}\bin位置創建符號鏈接。