node.jsangularnpmnpm-registry.npmrc

Adding .npmrc file to Angular project


I seem to be missing a whole step in doing this. I added an .npmrc file in the root of my angular project and added the following line inside it:

@example/xxx:registry=ssh/url/of/my/private/repo/in/bitbucket

And accordingly added @example/xxx in my package.json to install the dependency from my private repository.

However, the file seems to have no effect at all and not even recognized as when running npm install fails and returns an error for not finding my package on npm registry (which was expected). Is there something more i have to do other than simply creating .npmrc file in the root of the project?

My goal us to be able to push the project with the correct configuration so that every who has access to the package and project repo can simply pull the project and be able to install and use the private package.


Solution

  • Adding the following line in package.json of the angular project solves the problem:

    "package-name": "url/of/package/repo"
    

    But, I want to change the package scope and to be able to address it using @SCOPE/xxx:registry=......

    *Its a private package and it is not published.

    Edit: I simply had a typo. The following line in the .npmrc file worked:

    @SCOPE:registry=https://....
    

    The xxx part was not needed. Thanks to the gitlab package registry documentation.