npm - Cloudflare 页面部署 : Yarn install fails with 401 Unauthorized for fontawesome dependency

标签 npm deployment font-awesome yarnpkg cloudflare

在我安装 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 应用程序时遇到了这个问题。我能够使用 this guide 修复它来自 FontAwesome 网站。

不幸的是,此解决方法需要有效的身份验证 token 。幸运的是,我已经是 FA Pro 订阅者。

在项目的根目录中创建一个 .npmrc 文件并添加以下代码,将“TOKEN”替换为您的身份验证 token 。登录 FA 网站后,可以在上面链接的指南中找到授权 token 。

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

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

关于npm - Cloudflare 页面部署 : Yarn install fails with 401 Unauthorized for fontawesome dependency,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67766055/

相关文章:

javascript - Java Gradle 项目构建错误

javascript - 问题在 angular5 中添加第三方(外部)js 库

npm - 为什么我在启动 Expo 客户端时不断收到此错误代码

angularjs - 缺少脚本 : start Electron

javascript - Angular 应用程序必须在新部署后清除缓存

iis - 从 Visual Studio Team Services 中的构建部署到私有(private) IIS 服务器

asp.net - 在单个 Azure 云服务上部署多个 Web 角色和辅助角色

html - Font Awesome 图标元素空间有不需要的重叠

html - 是否可以使用图标字体显示 TextSelection?

html - 如何在没有危险设置InnerHTML的情况下在React中渲染HTML实体?