angularnpmartifactorynpm-registry

Publish angular library in enterprise artifactory


When i have setup npm repository at enterprise JFrog then following 5 npm repositories have been created:

npm-local
npm-release local
npm-generic-local
npm-central
npm-central-cache

And whenever i am trying to publish angular library by using npm publish command i am able to push artifacts to npm-local repository. But when i am trying to do npm install (in package.json both public and our dependencies are mentioned) so it's throwing 404 not found error, looks like it's not able to pull public artifacts from npmjs registry link.

Similarly, i am able to pull public artifacts from npmjs registry if i am pointing to npm-central repository in JFrog, but not able to publish our angular library there. It's throwing 400 bad request error.(Below error logs)

18 http fetch PUT 400 <JFrog_Url>/api/npm/npm-release-local/@ca-platform%2fcore 1592ms
19 verbose stack Error: 400 Bad Request - PUT <JFrog_Url>/api/npm/npm-release-local/@ca-platform%2fcore
19 verbose stack     at res.buffer.catch.then.body (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:104:15)
19 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
20 verbose statusCode 400
21 verbose pkgid @ca-platform/core@1.0.0
22 verbose cwd C:\Decomposition Projects\ca-ui-platform\ca-ui-platform\dist\core
23 verbose Windows_NT 10.0.17763
24 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "publish"
25 verbose node v10.19.0
26 verbose npm  v6.13.4
27 error code E400
28 error 400 Bad Request - PUT <JFrog_Url>/api/npm/npm-release-local/@ca-platform%2fcore
29 verbose exit [ 1, true ]

Can , anyone please help me to understand in which npm repository i have to point in JFrog so that i can push our libraries as well as pull public artifacts from same npm repository.

PS: I am using below configuration in .npmrc file for pointing to any npm repository at JFrog:

strict-ssl=false
registry=<JFrog_Url>/api/npm/npm-central/ 
_auth = <auth_token>
email = <email-id>
username= <username>
always-auth=true

Solution

  • npm-local npm-release local npm-generic-local are all local repositories from my understanding. You can publish and download packages from local repositories in Artifactory.

    However, npm-central is a remote repository that is pointing to npmjs.com. Remote repositories allows you proxying an upstream (in this case npmjs) but they won't allow you publishing new packages to it.

    You want to be able to both publish and resolve (i.e. download) packages from a single repository and this is where virtual repositories come into play.

    Virtual repositories allow you aggregating one or more local, remote and even virtual repositories in a single repository and by that, allowing you access to all of your packages in all of the aforementioned repositories. It will allow you both downloading and publishing of packages.

    Therefore, I suggest creating a virtual repository > aggregate npm-local and npm-central for example (you can add all of the remote and local repositories you have added) > specify the Default Deployment Repository which is the local repository in which published packages will be stored in (i.e. when you use the 'npm publish' command) > update your .npmrc file (don't forget to do 'npm login' to the new virtual repository).

    This way, you will have a single (virtual) repository allowing you downloading packages from npmjs (and the packages in your local repositories) and publishing packages to the local repository you selected.