簡體   English   中英

npm安裝不在/ usr / bin安裝東西

[英]npm install not installing things at /usr/bin

我正在嘗試安裝SailsJS:

$ sudo npm install -g sails

它可以使用以下日志在/ home / brunoluiz / npm / lib / node_modules / sails中安裝所有內容:

/home/brunoluiz/npm/bin/sails -> /home/brunoluiz/npm/lib/node_modules/sails/bin/sails.js
sails@0.9.16 /home/brunoluiz/npm/lib/node_modules/sails
├── connect-flash@0.1.1
├── pluralize@0.0.5
├── inflection@1.2.5
├── grunt-sails-linker@0.9.5
├── grunt-contrib-clean@0.4.1
├── node-uuid@1.4.0
├── async@0.2.9
├── grunt-contrib-concat@0.3.0
├── grunt-contrib-copy@0.4.1
├── grunt-contrib-coffee@0.7.0
├── ejs-locals@1.0.2
├── ejs@0.8.4
├── underscore.string@2.3.0
├── coffee-script@1.6.2
├── lodash@2.4.1
├── i18n@0.4.1 (debug@0.8.0, sprintf@0.1.3)
├── optimist@0.3.4 (wordwrap@0.0.2)
├── include-all@0.1.2 (underscore.string@2.3.1)
├── sails-disk@0.9.3 (waterline-criteria@0.9.7, lodash@2.3.0, fs-extra@0.8.1)
├── fs-extra@0.5.0 (jsonfile@0.0.1, ncp@0.2.7, mkdirp@0.3.5, rimraf@2.1.4)
├── connect-redis@1.4.5 (debug@0.8.0, redis@0.7.3)
├── grunt-contrib-jst@0.5.0 (lodash@1.0.1, grunt-lib-contrib@0.5.3)
├── glob@3.1.14 (inherits@1.0.0, graceful-fs@1.1.14, minimatch@0.2.14)
├── grunt-contrib-cssmin@0.6.1 (grunt-lib-contrib@0.6.1, clean-css@1.0.12)
├── grunt-cli@0.1.9 (resolve@0.3.1, nopt@1.0.10, findup-sync@0.1.3)
├── grunt-contrib-watch@0.4.4 (gaze@0.3.4, tiny-lr@0.0.4)
├── connect-mongo@0.3.2 (mongodb@1.2.14)
├── grunt-contrib-uglify@0.2.2 (grunt-lib-contrib@0.6.1, uglify-js@2.3.6)
├── waterline@0.9.16 (underscore@1.5.2, q@0.9.7, anchor@0.9.12)
├── grunt@0.4.1 (which@1.0.5, dateformat@1.0.2-1.2.3, eventemitter2@0.4.13, colors@0.6.2, hooker@0.2.3, async@0.1.22, nopt@1.0.10, minimatch@0.2.14, lodash@0.9.2, rimraf@2.0.3, coffee-script@1.3.3, underscore.string@2.2.1, iconv-lite@0.2.11, glob@3.1.21, findup-sync@0.1.3, js-yaml@2.0.5)
├── winston@0.7.1 (cycle@1.0.3, stack-trace@0.0.9, eyes@0.1.8, colors@0.6.2, pkginfo@0.3.0, request@2.16.6)
├── express@3.4.0 (methods@0.0.1, debug@0.8.0, range-parser@0.0.4, cookie-signature@1.0.1, fresh@0.2.0, buffer-crc32@0.2.1, cookie@0.1.0, mkdirp@0.3.5, commander@1.2.0, send@0.1.4, connect@2.9.0)
├── grunt-contrib-less@0.9.0 (grunt-lib-contrib@0.6.1, chalk@0.4.0, less@1.6.3)
└── socket.io@0.9.14 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.io-client@0.9.11)

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

Karma模塊也是如此。

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

聽起來你的npm安裝配置為使用/home/brunoluiz/npm作為prefix ,這意味着它會將符號鏈接放在{prefix}/bin全局安裝的包附帶的CLI中。

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

如果$PATH沒有{prefix}/bin則無法僅按名稱執行此類CLI。

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

npm get prefix

你的選擇是:

  • /home/brunoluiz/npm/bin$PATH

  • prefix配置項的值更改為bin子文件夾已在$PATH文件夾; 例如:

    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位置創建的符號鏈接的全局包。

除了mklement0的答案之外,第一個解決方案(將npm二進制目錄路徑添加到PATH變量)在Linux環境下使用sudo前綴運行命令時會產生另一個問題。 要解決此問題,還必須在/etc/sudoers.tmp中的secure_path中添加npm二進制目錄路徑。 方法如下: 為什么在將命令添加到PATH后sudo找不到命令?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM