Using a private npm package hosted on github package registry

  • Site name: lucid-johnson-940d56.netlify.app

Build log:

12:04:17 PM: Build ready to start
12:04:20 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
12:04:20 PM: build-image tag: v3.6.1
12:04:20 PM: buildbot version: b5aa40ef41f8f8b302713d535e9a3180a3b0e301
12:04:20 PM: Fetching cached dependencies
12:04:20 PM: Starting to download cache of 215.3MB
12:04:21 PM: Finished downloading cache in 1.170998782s
12:04:21 PM: Starting to extract cache
12:04:31 PM: Finished extracting cache in 9.594828692s
12:04:31 PM: Finished fetching cache in 10.951950452s
12:04:31 PM: Starting to prepare the repo for build
12:04:32 PM: Preparing Git Reference pull/236/head
12:04:35 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'out_publish' versus '/' in the Netlify UI
12:04:35 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'out_functions' versus '' in the Netlify UI
12:04:35 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'mv .env.staging .env.production && yarn build && yarn run next-on-netlify' versus '' in the Netlify UI
12:04:35 PM: Starting build script
12:04:35 PM: Installing dependencies
12:04:35 PM: Python version set to 2.7
12:04:36 PM: Started restoring cached node version
12:04:38 PM: Finished restoring cached node version
12:04:39 PM: v12.18.0 is already installed.
12:04:40 PM: Now using node v12.18.0 (npm v6.14.4)
12:04:40 PM: Started restoring cached build plugins
12:04:40 PM: Finished restoring cached build plugins
12:04:40 PM: Attempting ruby version 2.7.1, read from environment
12:04:42 PM: Using ruby version 2.7.1
12:04:42 PM: Using PHP version 5.6
12:04:42 PM: Started restoring cached node modules
12:04:42 PM: Finished restoring cached node modules
12:04:42 PM: Started restoring cached yarn cache
12:04:42 PM: Finished restoring cached yarn cache
12:04:43 PM: Installing NPM modules using Yarn version 1.22.4
12:04:43 PM: yarn install v1.22.4
12:04:43 PM: [1/4] Resolving packages...
12:04:44 PM: [2/4] Fetching packages...
12:04:45 PM: error An unexpected error occurred: "https://npm.pkg.github.com/download/@casavoco/baccanale/1.6.2/9309e91de1e1f1d00ed8a13cf37b9e7ad895c81649429d2a552c3dac4d7217ed: Request failed \"404 Not Found\"".
12:04:45 PM: info If you think this is a bug, please open a bug report with the information provided in "/opt/build/repo/yarn-error.log".
12:04:45 PM: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
12:05:21 PM: Error during Yarn install
12:05:21 PM: Build was terminated: Build script returned non-zero exit code: 1
12:05:21 PM: Failing build: Failed to build site
12:05:21 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:05:21 PM: Finished processing build request in 1m0.823258144s

We have a private npm package as dependency of our netlify app, but the build fails due to a 404 while trying to install the package @casavoco/baccanale.
We have followed the steps written in this comment.
The npmrc is the following:

//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
@casavoco:registry=https://npm.pkg.github.com

The install step is reading the .npmrc correctly, because before following the steps above, the install gave 401.

Hey :slight_smile: - Can you share your npmrc?

Have you used

//npm.pkg.github.com/:_authToken=${NPM_TOKEN}

as I noticed the comment you referred to was regarding GitLab and npm which suggested:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

Thanks!

//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
@casavoco:registry=https://npm.pkg.github.com

Hey, I noticed you’ve changed the line

@casavo:registry=https://npm.pkg.github.com

in your original post to:

@casavoco:registry=https://npm.pkg.github.com

Can you confirm casavoco is the account owner of the package, and also have you tried running a fresh build / clean cache since making this change? :slight_smile:

I was next going to suggest trying

registry=https://npm.pkg.github.com/casavoco

if you are only pulling from one private repo.

Can you also confirm that when you install dependencies in your project, it works locally?

Edit: I also read into [this](yarn does not honor authentication settings in .npmrc · Issue #4451 · yarnpkg/yarn · GitHub, you could try setting your build command to npm rather than yarn to see if that helps just to help focus down the issue. Although as you say it does seem like the npmrc is being read.

You could alternatively try adding a .yarnrc with

"@casavoco:registry" "https://npm.pkg.github.com"

The right one is:

@casavoco:registry=https://npm.pkg.github.com

I have noticed this typo while writing the post and I have run a build but there was the same error.

Now I have retried cleaning the cache and it works!

Perfect! Glad it was a quick fix for you!

@AaronP the solution did not work, I made a retry on the wrong build, without the private package. The situation is the same as always: a 404 while trying to install the package.

Hey @casavo-developer ! Damn, that’s a shame! Have you had a chance to read into the link I posted above along with the other details? Did they help at all?
See below:
I was next going to suggest trying

registry=https://npm.pkg.github.com/casavoco

if you are only pulling from one private repo.

Can you also confirm that when you install dependencies in your project, it works locally?

Edit: I also read into [this](https://github.com/yarnpkg/yarn/issues/4451 , you could try setting your build command to npm rather than yarn to see if that helps just to help focus down the issue. Although as you say it does seem like the npmrc is being read.

You could alternatively try adding a .yarnrc with

"@casavoco:registry" "https://npm.pkg.github.com"