【问题标题】:No command 'ember' found找不到命令“ember”
【发布时间】:2014-10-30 10:11:30
【问题描述】:

好像我搞砸了我的 ember-cli 安装。 我已经使用 sudo 安装了 npm,但是在阅读了 npm 上的 ember-cli 和 sudo 的一些问题后,我按照https://gist.github.com/isaacs/579814 的说明进行了卸载并重新安装。

现在我已经通过 npm install -g ember-cli 安装了 ember-cli,但是当我执行 ember new <name> 时,我得到了

没有找到命令“ember”,您的意思是:

来自包“asn1c”(宇宙)的命令“enber”

ember:找不到命令

我可以做哪个节点

$哪个节点

/home/[用户]/local/bin/node

以及哪个 npm

$哪个npm

/home/[用户]/local/bin/npm

,但我可以看到安装的以下路径中存在ember:

npm install -g ember-cli

/home/[user]/npm/bin/ember -> /home/[user]/npm/lib/node_modules/ember-cli/bin/ember

任何想法如何让 ember 命令正常工作?

【问题讨论】:

    标签: ubuntu npm ember-cli .bash-profile


    【解决方案1】:

    您需要确保/home/[user]/npm/bin 在您的shell 路径中。你可以echo $PATH看看有没有收录。

    对于 Bash:

    将此添加到您的 .bashrc.bash_profile

    PATH=/home/[user]/npm/bin:$PATH
    

    然后重启你的终端或者运行source ~/.bashrc

    对于 ZSH:

    将此添加到您的“.zshrc”

    path+=('/home/[user]/npm/bin')
    

    然后重启你的终端或者运行source ~/.zshrc

    您需要将路径中的[user] 替换为您计算机上的用户名。

    【讨论】:

    • path+=('/home/[user]/npm/bin') 这是做什么的?
    【解决方案2】:

    另一种方法是使用nvm。它使您无需 sudo 即可轻松管理 node.js/npm 版本,还可以管理已安装的包。一个缺点(或者可能不是?)是您必须为每个节点版本分别安装软件包。

    【讨论】:

      【解决方案3】:

      接受的答案有效。我不同意使用~/.bashrc~/.bash_profile~/.bashrc 仅用于非登录 shell,~/.bash_profile 用于登录 shell。

      我建议您导出到~/.profile 中的$PATH,这将可供整个桌面会话使用。

      因此,您应该添加类似的内容

      export PATH=$PATH:/home/[user]/npm/bin
      

      发送至~/.profile 以获得最佳效果

      【讨论】:

        猜你喜欢
        • 2021-02-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多