Apify and Crawlee Official Forum

Updated 5 months ago

Problem building with private packages

At a glance
Hi everyone, nice to be here 😁

I am writing to you about a problem with private packages on an Actor JS/Typescript- Engine Node 18.

I followed these steps:
  • I created a secret with the NPM_GITHUB_TOKEN
  • checked the option from GUI "Apply environment variables also to the build process"
  • I added these lines to my Dockerfile
ARG NPM_GITHUB_TOKEN ENV NPM_GITHUB_TOKEN=$NPM_GITHUB_TOKEN
and tried printing the value of the NPM_GITHUB_TOKEN in the build (it works)
  • I correctly created the .npmrc file that uses the NPM_GITHUB_TOKEN
I always get this error:

npm ERR!
2023-12-02T07:09:42.306Z 401 Unauthorized - GET https://npm.pkg.github.com/download/.........

Locally everything works correctly.
Has anyone had and solved a similar problem? I searched in old posts but couldn't find anything.
Thanks
L
m
A
8 comments
We did with adding this to Dockerfile before npm install

Plain Text
# <--- Copy the .npmrc file. --->
# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY code/package*.json code/.npmrc ./


Then having .npmrc file on top level with something like this

Plain Text
@apify-projects:registry=https://npm.pkg.github.com/apify-projects
//npm.pkg.github.com/:_authToken=ghp_vz34528RfdgfdgONJlfsdfFxVjsfdQRCT
ahh thanks , now it works, I was missing that little detail about not copying the .npmrc file, that had to be done in two different points
I also find out that it seems that it's possible to tell apify to apply env variable also during build time only from the GUI like this, there's no other way? I'm creating actor via apify-cli using apify-cli push and planning to automating it via github actions and obviously this will not work with this
This should be possible via API but not sure if CLI, good point, I will pass it to the team
Hi , by any change any update from the team on this?
just advanced to level 1! Thanks for your contributions! πŸŽ‰
Nope, I would not waitt for this for now
Add a reply
Sign up and join the conversation on Discord