簡體   English   中英

Node.js 錯誤:全局模塊:'找不到命令'

[英]Node.js error: global module: ' command not found '

解決方案:

  1. 權限錯誤 - 從Kadir 的評論中自信地修復
  2. Bower Sourcing of bin - 從Josiah 的評論中明確修復
  3. 須藤 chown -R $(whoami):admin /usr/local

.bower-profile

if [ -r ~/.profile ]; then . ~/.profile; fi
case "$-" in *i*) if [ -r ~/.bashrc ]; then . ~/.bashrc; fi;; esac

。輪廓

PATH=~/npm-global/bin:$PATH

原始錯誤軌跡

Mac OS X El 船長 | 節點 v5.0 | 新產品管理 3.4.0

npm 工作,像 git 這樣的全局命令工作。

項目中的bower -g不起作用。

Aarons-MacBook-Air:test2 Akorn$ ionic start todo blank
-bash: ionic: command not found
Aarons-MacBook-Air:test2 Akorn$ ionic --version
-bash: ionic: command not found
Aarons-MacBook-Air:test2 Akorn$ npm ionic -l -v
3.4.0

權限錯誤

Aarons-MacBook-Air:test2 Akorn$ brew update && brew upgrade node
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local
Aarons-MacBook-Air:test2 Akorn$ brew --version
Homebrew 0.9.5 (git revision fb84; last commit 2015-12-22)

問題我可以信任 sudo 修復嗎?

有沒有更好的解決辦法?

有沒有進一步診斷的方法?

我是怎么破解這個的?

  1. 錯誤地更新 npm 或節點 - 但是 npm 從錯誤的文件夾調用全局函數。

  2. 錯誤地使用 brew。

  3. .profile / .profile_bash丑陋代碼。

    ~/.bash_profile :

     source ~/.profile

    ~/.profile :

     export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

通常,當您看到-bash: mycommand: command not found這意味着您嘗試使用的命令不在 bash 正在查找的位置。 Bash 通常在當前工作目錄和$PATH環境變量中列出的任何位置中查找。

您可以通過運行echo $PATH來查看$PATH的當前值。 根據您發布的~/.profile內容判斷,您安裝ionic的位置不是您路徑的一部分。 您必須驗證該文件的安裝位置; 也許/Users/Akorn/npm-global/lib或者在/usr/local/bin/usr/bin安裝了快捷方式,因此您也需要檢查它們並確保將它們添加到您的$PATH 例如,我的$PATH看起來像這樣; /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/Josiah/docker/bin

要了解如何向$PATH添加新位置,請閱讀此問題的第一個答案

暫無
暫無

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

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