Packages / do npm tags work ?


I am using a Github Action to publish to Github Packages (npm):


on: push

    runs-on: ubuntu-latest
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
        node-version: 12
        registry-url: ''
        scope: '@PeterHewat'
    - run: npm publish # --tag next
      continue-on-error: true
        NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

If I use the command “npm publish” in my workflow, it creates a package using the current version defined in my packages.json. This works fine. What I do not understand is that if I use the command “npm publish --tag next” in order to specify an npm tag to my package, the package is generated, but I find no trace of the tag. There is a difference though: the package isn’t listed as being the latest (cf. 1.0.5 / 1.0.6):


What I would like to do is manage npm tags in order to be able to target latest/next dependencies like what is done here for example:

Does Github Packages support this?

For now, if I run the command “npm install github:peterhewat/test-packages@next” I get the error “…is not a valid repository name”. I have to remove the tag at the end as follows: “npm install github:peterhewat/test-packages”. This will install the last package created even if it is not specified as “latest version” (ie. 1.0.6 instead of 1.0.5 which is the “latest version”).

I tried to publish a new version 1.0.1 with next tag to my package, the same as yours, the latest version is still the previous one.  

I managed to install package with tag next in the following example: 

npm install @yanjingzhu/npmpackages@next

npm install.png 

There is the result: 

Please check whether this could work for you.

Hi @yanjingzhu 

Thanks for your message. Unfortunetly, it doesn’t work. If you publish another package with a different tag (ex: “beta”), it won’t be taken into account. The dependency @next will just get the latest package ignoring the “next” and “beta” tags.

I got the following reply from GitHub Support:

Hi Peter,

Thanks for reaching out.

-- Does Github Packages support this?

Publishing a node package using --tag isn't supported, however you could use a
distribution tag instead– Ie. npm dist-tag add @owner/package@x.x.x latest and
then perform the install using npm install @owner/package@latest.

Please let me know if you need something else.



My initial tests with dist-tag haven’t worked either. I’ll keep on looking into this.

Hello again @yanjingzhu 

–tag does seem to work for my use case after all.



1 Like

I am so glad to hear that you have resolved your issue. In my example, I also used  npm publish --tag next as you said . 

next tag.png

One of the last pages of packages handels about combination of automatisation and modification, actions

That I must evaluate first, but yes it’s the only exception with packages. The last example I guess

Good job! I was sure it worked in theory, but when I read about it I was sure that someone was bullying me again. It’s fun if it’s friendly, strange doug that yesterday everyone believed that woman. Then I panicked.

Are you now the issuer? Or am I wrong?

What a pithy. It should be good training stuff.

npm publish --tag CUSTOM_TAG is work. but npm dist-tag add @owner/package@version tag is not work.

❯ npm dist-tag add @owner/package@$VERSION $TAG
npm ERR! code E404
npm ERR! 404 Not Found - GET
npm ERR! 404 
npm ERR! 404  '@owner/package@version' is not in the npm registry.