2

使用 yarn 安装 packages 之后出现 command not found 问题的解决办法

 2 years ago
source link: https://blog.diqigan.cn/posts/command-not-found-error-in-yarn-packages.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用 yarn 安装 packages 之后出现 command not found 问题的解决办法

发表于

2019-03-15 更新于 2019-08-23 分类于 coding

阅读次数: 2002 Valine: 本文字数: 478 阅读时长 ≈ 1 分钟

最近了解到 nodejs 的一款新的包管理器 yarn, 据说相对于 npm 来说有许多优点。遂果断开启试用流程,无奈遇到使用 yarn 安装 packages 之后出现 command not found 的问题,这里写出我自己的解决方法.

  1. OS: Ubuntu 18.10 x86_64
    Kernel: 4.18.0-16-generic
    Shell: zsh 5.5.1

    非 root 用户登录.

    • 使用 yarn 安装 Angular CLI

      yarn global add @angular/cli

      提示安装成功.

    • 运行 ng 命令却提示 command not found.

    • yarn 全局安装的包其实是在 ~/.yarn/bin/ 目录下的,只需将这个目录配置到系统环境变量即可.

      echo 'export PATH=~/.yarn/bin/:$PATH' >> ~/.zshrc
      source ~/.zshrc

      问题解决.

    • 非 zsh 终端的用户可以将上述命令中的 .zshrc 改为 .profile 即可.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK