anshul
anshul

Reputation: 791

I cannot publish to npm

i'm trying to publish a demo button component to npm and have followed this tutorial

My package.json

{
  "types": "dist/index.d.ts",
  "files": [
    "dist"
  ],
  "publishConfig": {
    "registry": "https://npm.pkg.github.com/abhinav-anshul"
  },
  "name": "@abhinav-anshul/avyav",
  "version": "1.0.5",
  "description": "",
  "main": "dist/cjs/index.js",
  "module": "dist/esm/index.js",
  "scripts": {
    "rollup": "rollup -c"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@rollup/plugin-commonjs": "^21.0.1",
    "@rollup/plugin-node-resolve": "^13.1.3",
    "@rollup/plugin-typescript": "^8.3.0",
    "@types/react": "^17.0.38",
    "react": "^17.0.2",
    "rollup": "^2.63.0",
    "rollup-plugin-dts": "^4.1.0",
    "typescript": "^4.5.4"
  }
}

My .npmrc :

always-auth = true
registry=https://registry.npmjs.org/
@abhinav-anshul:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=<TOKEN CREATED USING GITHUB>

My Github repo for the same here

The problem I'm facing is :

  1. I have added a token and published as a "github package", I can see it successfully published on my terminal, and on the github package as well, Under the repo, it is instructing me to do npm install @abhinav-anshul/[email protected]

  2. However, when I try to install in a different project altogether, the error message I get is

npm ERR! 404 Not Found - GET https://registry.npmjs.org/@abhinav-anshul%2favyav - Not found
npm ERR! 404 
npm ERR! 404  '@abhinav-anshul/[email protected]' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
  1. Also, I cannot find by searching the package on the npmjs.org website too.

Things I'm not sure about:

  1. Is it because of my token?
  2. If something is published as a github package and it does instructs me to install it using npm, then why it is not available on the npmjs site? Are those two different things?

Any input in the right direction would be quite helpful. I'm trying to publish a package for the first time, sorry in case I missed out anything obvious.

Thank You for reading.

Upvotes: 1

Views: 1151

Answers (2)

Yougourtha Berrani
Yougourtha Berrani

Reputation: 11

Your repo is private, you need to create token with the specific authorizations as explained in the tutorial, or just make it public.

Upvotes: 1

kevintechie
kevintechie

Reputation: 1521

That tutorial shows how to publish a package to GitHub Packages. Therefore, you will not be able to find it on npmjs.org. You can find your package on GitHub.

GitHub launched its package repository (similar to npmjs.org) in 2019. npm (the tool) and yarn will install packages from both repositories.

You may be getting this error if you have previously installed this code directly from the GitHub code repository vs. the package repository. Try deleting your package-lock.json to fix this.

Upvotes: 2

Related Questions