CA
rare-sapphire

Problem building with private packages

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
7 Replies
correct-apricot
correct-apricot2y ago
We did with adding this to Dockerfile before npm install
# <--- 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 ./
# <--- 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
@apify-projects:registry=https://npm.pkg.github.com/apify-projects
//npm.pkg.github.com/:_authToken=ghp_vz34528RfdgfdgONJlfsdfFxVjsfdQRCT
@apify-projects:registry=https://npm.pkg.github.com/apify-projects
//npm.pkg.github.com/:_authToken=ghp_vz34528RfdgfdgONJlfsdfFxVjsfdQRCT
rare-sapphire
rare-sapphireOP2y ago
ahh thanks @Lukas Krivka , 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
rare-sapphire
rare-sapphireOP2y ago
No description
correct-apricot
correct-apricot2y ago
This should be possible via API but not sure if CLI, good point, I will pass it to the team
rare-sapphire
rare-sapphireOP2y ago
Hi @Lukas Krivka , by any change any update from the team on this?
MEE6
MEE62y ago
@milloome just advanced to level 1! Thanks for your contributions! 🎉
correct-apricot
correct-apricot2y ago
Nope, I would not waitt for this for now

Did you find this page helpful?