Cannot deploy new v4 strapi project to Heroku or Render - getting "401 Unauthorized" error on fontawesome request

System Information
  • Strapi Version: 4.1.5
  • Operating System: Windows 10
  • Database: Postgre
  • Node Version: 16.14.1
  • NPM Version:
  • Yarn Version: 1.22.17

I am trying to create a brand new strapi v4 project and that works fine locally but when I try and deploy it to Render or Heroku (which I’ve done before many times on Strapi v3) I get a build error when it tries to grab fontawesome-free-5.15.4.tgz from fontawesome. The error log I get on both Render and Heroku is:

 error An unexpected error occurred: "https://npm.fontawesome.com/@fortawesome/fontawesome-free/-/5.15.4/fontawesome-free-5.15.4.tgz: Request failed \"401 Unauthorized\"".
       info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_2d005b2a/yarn-error.log".

Is there something I can do to solve the issue? If I go to https://npm.fontawesome.com/@fortawesome/fontawesome-free/-/5.15.4/fontawesome-free-5.15.4.tgz myself, it asks for a username and password so I’m assuming that when Render/Heroku try and hit that URL they don’t have a username and password to send. (And the same goes for all the different npm.fontawesome.com links in the yarn.lock file).

If this is the case, why does the project build and run fine locally? Shouldn’t I also have to input those credentials? Do they need to be added as environment variables on Render/Heroku somehow?

Sorry, I’m quite new to all this! I was following this tutorial on the Strapi blog: Deploy a Strapi API on Heroku in 5 min

Any help is greatly appreciated.

Thanks!

P.S. Here is the full error log from Heroku:

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       USE_YARN_CACHE=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  >=12.x.x <=16.x.x
       engines.npm (package.json):   >=6.0.0
       engines.yarn (package.json):  unspecified (use default)
       
       Resolving node version >=12.x.x <=16.x.x...
       Downloading and installing node 16.14.1...
       Bootstrapping npm >=6.0.0 (replacing 8.5.0)...
       npm >=6.0.0 installed
       Resolving yarn version 1.22.x...
       Downloading and installing yarn (1.22.17)
       Installed yarn 1.22.17
       
-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.17
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       error An unexpected error occurred: "https://npm.fontawesome.com/@fortawesome/fontawesome-free/-/5.15.4/fontawesome-free-5.15.4.tgz: Request failed \"401 Unauthorized\"".
       info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_2d005b2a/yarn-error.log".
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Dangerous semver range (>) in engines.node
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed
1 Like

I’m going to just reply to this in case it helps anyone else see it.

I’m still having this issue on both Heroku and Render with a clean install of a strapi v4 project.

Is anyone else having this issue? Does anyone know a way around it?

Thanks

I just had the same issue. The problem was that at ~/.npmrc I had a file with tokens from a previous project. This made it so that in yarn.lock there were references to npm.fontawesome.com instead of https://registry.yarnpkg.com/@fortawesome/...

So:

  1. remove ~/.npmrc
  2. remove lock file
  3. install dependencies again

This solved the issue for me

Thanks @kero! I was at a loss so thanks for finding the issue! It’s all working now.

I just ran into this issue and followed the steps from @kero but I’m still getting an error when trying to deploy in Render. I’m assuming font awesome was indeed the culprit because I did have an auth token for font awesome previously set in my .npmrc. However, after removing the file, I’m still getting 401 from Render.

npm ERR! code E401
Sep 30 01:21:02 PM  npm ERR! Incorrect or missing password.
Sep 30 01:21:02 PM  npm ERR! If you were trying to login, change your password, create an
Sep 30 01:21:02 PM  npm ERR! authentication token or enable two-factor authentication then
Sep 30 01:21:02 PM  npm ERR! that means you likely typed your password in incorrectly.
Sep 30 01:21:02 PM  npm ERR! Please try again, or recover your password at:
Sep 30 01:21:02 PM  npm ERR!     https://www.npmjs.com/forgot
Sep 30 01:21:02 PM  npm ERR!
Sep 30 01:21:02 PM  npm ERR! If you were doing some other operation then your saved credentials are
Sep 30 01:21:02 PM  npm ERR! probably out of date. To correct this please try logging in again with:
Sep 30 01:21:02 PM  npm ERR!     npm login
Sep 30 01:21:02 PM  
Sep 30 01:21:02 PM  npm ERR! A complete log of this run can be found in:
Sep 30 01:21:02 PM  npm ERR!     /opt/render/.cache/_logs/2022-09-30T20_21_02_068Z-debug.log
Sep 30 01:21:02 PM  ==> Build failed 😞

Any other ideas or solutions to this?

Thanks!

Okay, it only worked for me after adding back my .npmrc, replacing the old contents of that file, then once again clearing package-lock.json and re-installing dependancies. Since this was very unclear, I first tried replacing my .npmrc and just setting it to the standard registry, without any better idea what to do, and that ended up working for me:

npm config set registry "https://registry.npmjs.com/"

Not sure what else would also work here, but in any case this finally solved it for me.