安装Yarn后,使用时报错的解决方法

334 阅读1分钟

今日使用yarn编译项目时遇到一个问题,使用npm install yarn -g安装Yarn后,在项目中执行yarn install报了如下错误信息:

> yarn install
yarn : The term 'yarn' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is cor
rect and try again.
At line:1 char:1
+ yarn install; $function:__FleetPatchPwshPrompt.Invoke()
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (yarn:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

查找了一些博客,都没有能够有效解决,无奈,最后只能到官方文档查看。

发现原来是Yarn对不同Node.js版本的安装和启用方式不同, 可以自行去官方文档(最新版本文档)查看。

文档地址:www.yarnpkg.cn/getting-sta…