I am using a private package from GitHub. When attempting to deploy, Heroku ignores my .npmrc
file configs.
Locally, my environment file looks like:
NPM_CONFIG_GITHUB_TOKEN=[token]
Then, my .npmrc
file looks like this:
[username]:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
With this configuration, I'm able to run this locally just fine. In Heroku, I get the following error:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_GITHUB_TOKEN=[token]
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 12.13.x
engines.npm (package.json): unspecified (use default)
Resolving node version 12.13.x...
Downloading and installing node 12.13.1
Using default npm version: 6.12.1
-----> Restoring cache
Cached directories were not restored due to a change in version of node, npm, yarn or stack
Module installation may take longer for this build
-----> Installing dependencies
Installing node modules
npm ERR! code E401
npm ERR! 401 Unauthorized - GET https://npm.pkg.github.com/download/[package]
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.P5iPk/_logs/2020-08-03T18_44_16_744Z-debug.log
-----> Build failed
The full logs say the same thing. However, if I change .npmrc
to:
[username]:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
... It work just fine in Heroku, but breaks locally.
Can anyone offer some guidance on what I'm doing wrong here? I've researched this for hours with no success. While the obvious solution is a different local version, this is an opensource project and I want to be able to provide straightforward installation directions.
When I deploy to Heroku I usually set the environment variables in my app settings on Heroku and I've never had a problem, you could try that