Downloading private npm package from artifactory

site name: admiring-sammet-ff69ee

Hello, I am looking to pull a private NPM package from my internally hosted Artifactory. I have been through this thread extensively [Support Guide] Using private NPM modules on Netlify

What I have tried:

  1. Setting a .npmrc in a .netlify folder, and modifying the .toml file to read from that.
  2. Using the suggested preinstall script netlify-preinstall.js and attaching that script to the preinstall hook.
  3. Tried replacing .npmrc with .yarnrc

In these solutions, I have printed out the files/folders in my directory in the script to confirm that .npmrc is not created initially, and printing out files/folder and the contents of .npmrc after.

The .npmrc is confirmed to be created with the correct internal contents, but I still get a 401 error upon trying to download the package.

Error:
Request failed "401 Unauthorized"".

11:58:59 AM: info If you think this is a bug, please open a bug report with the information provided in “/opt/build/repo/yarn-error.log”.

The only solution that has worked is to put a .npmrc at the root of my repo, however this is non-ideal as it requires engineers to set the envvar in their zsh/bash or export those variables.

Let me know if there is something I am doing wrong.

Thank you

Hey @kotybond, could you explain how exactly you did this? From my understanding, this file should exist in your base path. Did you change the base path in your TOML file?

Yeah, I copied my .npmrc file into .netlify, fielding a structure of, .netlify/.npmrc.

My TOML file looks like:

[build]
  NPM_CONFIG_USERCONFIG = "./netlify/.npmrc"

In that case, this line looks incorrect. Shouldn’t it be /.netlify/.npmrc?

But considering that’s a typo, have you referred to some documentation or something that says this is supported? Because I don’t think it is.

This is where I got the solution from, which also starts with ./. I can also try /.netlify, if you think it would help

I said it should be ./.netlify, because of:

If you’ve named your folder .netlify, the above path should be the correct one.