yarn 安装全局包后找不到命令的问题

使用 yarn 安装一个全局包:

yarn global add typescript

在命令行输入 tsc 命令 回车报错:

C:\Users\Administrator>tsc
'tsc' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

解决方案:

yarn global bin 获取 yarn 全局安装包路径,添加到系统环境变量中。

C:\Users\Administrator>yarn global bin
C:\Users\Administrator\AppData\Local\Yarn\bin

然后在 cmd 中输入 tsc 命令,此时已经可以正常使用了。


C:\Users\Administrator>tsc
Version 3.5.3
Syntax:   tsc [options] [file...]

Examples: tsc hello.ts
          tsc --outFile file.js file.ts
          tsc @args.txt
          tsc --build tsconfig.json

 

你可能感兴趣的:(问题记录,JavaScript,yarn)