2015-12-23 42 views
-1

解决方案“未找到命令”:Node.js的错误:全局模块:

  1. 权限错误 - 固定与评论信心通过卡迪尔
  2. 斌鲍尔采购 - 固定与清晰度从约西亚评论
  3. 须藤乔敦 - R的$(WHOAMI):管理员在/ usr /本地

.bower瞩目

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

的.profile

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

原来的错误开拓者

Mac OS X的船长巨岩|节点v5.0 | NPM 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* 
    
+0

您是否注意到“错误:/ usr/local目录不可写入”。在运行'brew'命令后行?这应该可能与权限错误有关。当你运行'ls -l/usr'时,你在** local **目录中看到了什么权限?你有没有试过这样的建议,你应该运行'sudo chown -R $(whoami):admin/usr/local' – Kadir

+0

$ ls -l/usr> local读取'root wheel'然后我运行了sudo代码,现在>本地读取'Akorn Admin'**弓**弓我害怕sudo,但现在我明白这条线执行什么 – Akorn

回答

1

一般来说,当你看到-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添加新位置,请阅读the first answer to this question

+0

$ echo $ PATH /Users/Akorn/npm-global/bin:/ usr/local/bin: /usr/bin:/bin:/usr/sbin:/sbin:/Users/Akorn/.rvm/bin **弓弓你的清晰度照亮了一个黑暗的角落。 – Akorn