During the build process, Fontawesome is causing a 401 unauthorized error

After smoothly using fontawesome for several months without any problems, I encountered an error today while attempting to push my app to production.

An unexpected error occurred: "https://npm.fontawesome.com/@fortawesome/fontawesome-pro/-/6.1.1/fontawesome-pro-6.1.1.tgz: Request failed "401 Unauthorized"".

Despite trying various solutions such as running yarn install, deleting node_modules, and removing yarn.lock, the 401 unauthorized error persisted. I even uninstalled and reinstalled all fontawesome packages.

Using Yarn instead of NPM adds another layer of complexity to this issue. I have a .npmrc file set up with the following content:

// .npmrc

@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken="my-token"

Additionally, there is a .yarnrc.yml file in place:

// .yarnrc.yml

npmScopes:
  fortawesome:
    npmRegistryServer: "https://npm.fontawesome.com/"
    npmAlwaysAuth: true
    npmAuthToken: "my-token"

Provided below is my package.json:

{
  "name": "br-client",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    ...
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    ...
  }
}

Answer №1

After investigating, I discovered that the issue was related to my dockerfile configuration. To properly install fontawesome, it is recommended in their instructions to execute the following commands in your terminal:

npm config set "@fortawesome:registry" https://npm.fontawesome.com/
npm config set "//npm.fontawesome.com/:_authToken" "your token here"

However, if you are using docker, these commands should be included in your dockerfile:

RUN npm config set "@fortawesome:registry" https://npm.fontawesome.com/
RUN npm config set "//npm.fontawesome.com/:_authToken" "your token here"

This ensures that the configuration is applied during deployment.

Therefore, my complete dockerfile now appears as follows...

FROM node:14-alpine

WORKDIR /usr/src/app
RUN npm config set "@fortawesome:registry" https://npm.fontawesome.com/
RUN npm config set "//npm.fontawesome.com/:_authToken" "my token"
COPY package*.json ./
COPY yarn.lock ./
RUN yarn install

COPY . .

RUN yarn build

EXPOSE 3000

CMD [ "yarn", "start" ]

Answer №2

When utilizing the .npmrc file as instructed on Font Awesome's official website, you have the option to include this specific line in order to import that file into the Docker environment.

This method is also compatible with yarn.

COPY .npmrc ./

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering error message "no such file or directory" while attempting to run lerna bootstrap

Struggling to execute the following command lerna bootstrap --hoist On a project I downloaded from GitHub. The steps are to Download Then run lerna bootstrap --hoist However, every time I try running the lerna bootstrap --hoist command, it fails with an ...

Error when trying to add style-loader in Vue.js 2 due to webpack installation issue

My task is to set up the style-loader in order to load import 'bootstrap-icons/font/bootstrap-icons.css'. However, when I run npm install style-loader, I encounter the following error message: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to re ...

What steps should be taken to upgrade a ReactJS project to utilize Node.js version 18.12.0 and npm version 8.19.2

Having recently updated my Node.js version to 18.12.0, I encountered some errors when trying to run my React.js project with the command npm start. The errors displayed were: Compiled with problems:X ERROR in ./src/assets/images/arrow_vector.svg Module ...

Building the Django+React app using `npm run build` is taking an extended amount of

As of late, I made the transition to React and have become quite familiar with it. Now, I have started integrating React with Django for backend support. After setting everything up, everything was working smoothly. However, every time I make changes to ...

Even after installing npm3, the npm -v command continues to display version 2.x.x

As I delve into the world of Angular 2, I learned that it requires npm version 3.x.x. Despite installing npm3 with the command npm install -g npm3, when I check my npm version using npm -v, it still shows as 2.15.8. Strangely, running npm3 -v displays vers ...

encountering difficulties while trying to install packages using npm

I encountered some issues while setting up a react-app and attempted to resolve them by deleting /node-modules and reinstalling, but the problems persist. I'm using Ubuntu as my operating system. Can someone assist me with this? Below is the error log ...

Incorporate DynamoDb functionality into your Sails js application

Recently, I embarked on a project using Sailsjs with DynamoDB as the database. During my research, I came across a helpful package at https://github.com/dohzoh/sails-dynamodb. The documentation provided detailed instructions for the initial setup. After i ...

"Exploring the world of npm packages alongside the powerful angular-cli tool

Is it better to package angular2 components in an npm module with the source files (*.ts, *.css, *.html) or the webpack compiled version for use in applications compiled with angular-cli@webpack? What should actually be published in the npm package? The r ...

What are the best steps to follow when creating a new package within a lerna monorepo?

I have recently come into possession of a monorepo that contains a packages folder housing all the current packages. My goal is to include a new main package that is essential for my existing panel package, which is currently at version 0.34.0. Since I fre ...

I keep running into errors whenever I try to run npm install in my React JS project. The only way for me to successfully install dependencies is by using npm install --force. How can I go about resolving these

I am encountering this error message while working on my project: npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @mui/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="681b1c11040d1b ...

Runtime not able to identify new modifications post migration from Angular 2 to Angular 6

I successfully upgraded my Angular 2 project with DotNetCore to Angular 6 by executing the following command: npm install -g npm-check-updates ncu -u After completing the migration process, I found that while I can still run my previously developed proje ...

The function Server.listeners is not recognized by the system

Currently, I am following a tutorial on websockets to understand how to incorporate Socket.IO into my Angular project. Despite meticulously adhering to the instructions provided, I encountered an error when attempting to run my websockets server project: ...

Error executing generateservertestreport script in npm run script

While executing an npm script through a TFS build, I encounter an issue. However, running the same script directly on the TFS build machine does not show any errors. Note: My node version is 8.12.0 and npm version is 6.4.1 Despite researching the cause o ...

What is the reason behind the abundance of packages in my node_modules directory?

As a newcomer to app development, I followed the npm create-react-app documentation to create my first app. However, I noticed that there were numerous packages included in the node_module folder that weren't essential for my basic use of React and Re ...

Steps for integrating libraries with Hyperledger peer (Node.js, npm)

How can libraries be added to a Hyperledger Docker container in order to run tools like node and npm from the Hyperledger peer container? Is it possible to achieve this easily using the docker-compose.yml file? An error is encountered while attempting a ...

What steps should I take to resolve the issue I am encountering while attempting to install packages using npm

npm ERR! Linux 4.15.0-36-generic npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "create-react-app" npm ERR! node v8.10.0 npm ERR! npm v3.5.2 npm ERR! path /tmp/npm-7054-19e3727d npm ERR! code EROFS npm ERR! errno -30 npm ERR! syscall mkdir n ...

Tips for updating the route using NPM serve

Hey there! I'm currently experimenting with the serve npm package. My goal is to serve static files on a different route. Here's an example of the directory structure I want to serve: index.html index.js helpers helper.js I've been tryi ...

Having trouble installing Firebase CLI through npm

After successfully installing node and npm, I proceeded to install the firebase CLI by following the steps outlined in this guide. First, I ran the command: Ahmads-MacBook-Pro:~ ahmadbazzi$ npm install -g firebase-tools This installation process generate ...

Issue encountered during the creation of a new Angular application (npm ERROR! 404 Not Found: @angular/animations@~7.1.0.)

I am currently using Windows 10, Node v11.0.0, and Angular CLI: 7.1.4. I encountered an error when trying to create a new Angular application. The error message is npm ERR! code E404 npm ERR! 404 Not Found: @angular/animations@~7.1.0. Error stack: 0 info ...

Using npm-update in conjunction with npm-shrinkwrap.json

Can anyone explain the impact of running: npm update when an npm-shrinkwrap.json file is present? Will it Align the dependencies with the shrinkwrap.json file Follow the package.json for dependencies (ignoring the shrinkwrap.json file) Have no effect ...