PS F:\ls\quick_redis_blog-2.7.0-alpha> 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 correct and try again.
At line:1 char:1
+ yarn install
+ ~~~~
+ CategoryInfo : ObjectNotFound: (yarn:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
在vscode控制台输入(全局安装yarn) :npm install -g yarn
PS F:\ls\quick_redis_blog-2.7.0-alpha> npm install -g yarn
added 1 package in 7s
npm notice
npm notice New patch version of npm available! 10.2.4 -> 10.2.5
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.5
npm notice Run npm install -g npm@10.2.5 to update!
npm notice
在执行,报错如下:
PS F:\ls\quick_redis_blog-2.7.0-alpha> yarn install
yarn : File C:\Program Files\nodejs\yarn.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Ptem. For more information, see about_Execution_P
olicies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ yarn install
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
报错原因:
这是由于 Windows PowerShell 自动阻止不信任的脚本执行造成的,因此需要更改 Windows PowerShell 执行策略。
要更改默认(LocalMachine)作用域的执行策略,请使用“以管理员身份运行”选项启动 Windows PowerShell。
要更改当前用户的执行策略,请运行 “Set-ExecutionPolicy -Scope CurrentUser”。