Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudflare Pages Deployment: Yarn install fails with 401 Unauthorized for fontawesome dependency

Deployments worked fine before I installed FontAwesome. Locally it works fine even with FontAwesome. But with FontAwesome dependency installed Cloudflare fails.

Console log from 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
like image 690
MissJulie Avatar asked Sep 06 '25 22:09

MissJulie


1 Answers

I just had this issue when trying build a Strapi app on DigitalOcean. I was able to fix it using this guide from the FontAwesome website.

Unfortunately, this workaround requires a valid auth token. Luckily for me, I was already an FA Pro subscriber.

Create an .npmrc file in the root of your project and add the below code, replacing "TOKEN" with your auth token. The auth token can be found on the guide linked above once logged into the FA website.

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

I'm not well versed enough in npm authentication to know why the free version would require this, but I'm sure there must be another workaround for free users of FA.

like image 172
Lee Buckle Avatar answered Sep 11 '25 12:09

Lee Buckle