I’m trying to run a Node.js app with private packages. These packages are hosted on GitHub packages. I created a personal access token and added a .npmrc file to my repository.

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

The token is provided my an environment variable.

When building the app on App Platform, I get this error:

backend | 12:18:10 Installing node_modules using yarn
backend | 12:18:11 yarn install v1.22.10
backend | 12:18:11 [1/4] Resolving packages...
backend | 12:18:11 error Couldn't find package "@my-org/my-package" on the "npm" registry.
backend | 12:18:11 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
backend | 12:18:11 unable to invoke layer creator
backend | 12:18:11 installing node_modules: exit status 1
backend | 12:18:11 ERROR: failed to build: exit status 1
backend | 12:18:11  ! Build failed (exit code 7)

Does App Platform not read the .npmrc file? Also why is it using yarn for installing the dependencies? I specifically avoided yarn because of problems with private GitHub packages.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi @Salzian!

If a yarn.lock file exists, App Platform will use Yarn. Otherwise, if a package-lock.json file exists, it will use NPM. It seems like Yarn doesn’t read .npmrc files, so that’s why it’s failing trying to pull your private package.

Hey @Salzian I ran into the same issue and what I ended up doing (since the offending package was a Dockerized server) was ensure that I copied all shared packages to the Docker file. That worked for me.

Submit an Answer