Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Using a private NPM package registry in the Frontend module.

Avatar

Level 1

Hey everyone,

 

We've been integrating some custom modules in our Frontend and started using GitLab Package Registries. It's got to the point where it's all working without a hitch locally, by providing the registry URL including token via .npmrc. But as soon as we try to deploy it to the Cloud Manager, the build fails stating that the Package cannot be found; see also below:

 

15:04:35,038 [Exec Stream Pumper] [INFO] npm ERR! code E404
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404 Not Found - GET https://gitlab.org.de/api/v4/packages/npm/@org%2fpackage
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404 
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404  '@org/package@1.0.4' is not in the npm registry.
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404 It was specified as a dependency of 'ui.frontend'
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404 
15:04:35,039 [Exec Stream Pumper] [INFO] npm ERR! 404 Note that you can also install from a
15:04:35,040 [Exec Stream Pumper] [INFO] npm ERR! 404 tarball, folder, http url, or git url.

 

Does AEM automatically locate the .npmrc when it's placed under ui.frontend or do we have to set it up to load it by e.g. providing it via pom.xml? If so, how would we achieve that? Is this approach even possible and if not are there any alternatives?

 

Best regards.

3 Replies

Avatar

Community Advisor

Please follow below steps 

  • set up a secret as pipeline variable to make it available for the build
    aio cloudmanager:set-pipeline-variables <PIPELINE_ID> --programId=PROGRAM_ID> --secret NPM_PRIVATE_REPO_AUTH <npm-auth>
  • This authentication information can then be referenced from the .npmrc file in the source repository. In the following example, the scope "corp" is downloaded  from a private repository

    @corp:registry=https://artifacts.corp.com/cloud-manager //artifacts.corp.com/cloud-manager/:_auth=${NPM_PRIVATE_REPO_AUTH}
    //artifacts.corp.com/cloud-manager/:always-auth=true

    Please refer this link for more details : 

     

    https://www.netcentric.biz/insights/2020/08/private-repository-cloud-manager.html

Avatar

Level 1

Thank you for your reply. We followed that guide and set it up like that, but it's still throwing the error that it can't find the package. Locally it works, just as soon as it's deploying through the Cloud Manager it's not.

 

I'm assuming that it either does not load the .npmrc file in the ui.frontend module when deploying with the cloud manager or maybe there's some kind of restrictions on where packages can be loaded from by the pipeline. But we've been using direct link (e.g. git+https://tokenname:token@...) as a workaround for now, so I guess there aren't any restrictions on package locations.