Cloudflare Pages部署:Yarn安装失败,401未经授权,依赖于font真棒



在安装FontAwesome之前,部署运行良好。在当地,即使使用FontAwesome也能很好地工作。但安装了FontAwesome依赖项后,Cloudflare失败了。

Cloudflare Pages:的控制台日志

23:32:59.378    Installing NPM modules using Yarn version 1.22.4
23:32:59.751    yarn install v1.22.4
23:32:59.851    [1/4] Resolving packages...
23:33:00.491    [2/4] Fetching packages...
23:33:00.802    error An unexpected error occurred: "https://npm.fontawesome.com/@fortawesome/free-solid-svg-icons/-/5.15.3/free-solid-svg-icons-5.15.3.tgz: Request failed "401 Unauthorized"".
23:33:00.802    info If you think this is a bug, please open a bug report with the information provided in "/opt/buildhome/repo/yarn-error.log".
23:33:00.802    info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
23:33:23.195    Error during Yarn install
23:33:23.195    Failed: build command exited with code: 1

我在DigitalOcean上构建Strapi应用程序时遇到了这个问题。我可以使用FontAwesome网站上的指南来修复它。

不幸的是,此解决方法需要有效的身份验证令牌。幸运的是,我已经是FA Pro的用户了。

在项目的根目录中创建一个.npmrc文件,并添加以下代码,替换";TOKEN";使用您的auth令牌。登录FA网站后,可以在上面链接的指南中找到auth令牌。

@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=TOKEN

我对npm身份验证还不够精通,不知道为什么免费版本需要这样做,但我相信对于FA的免费用户来说,肯定有另一种解决方法。

最新更新