I just created a new package.
I'm now trying to publish it to NPM for the first time like this:
ole#MKI:~/Sandbox/pli$ npm publish --access public
npm ERR! publish Failed PUT 404
npm ERR! Linux 3.13.0-93-generic
npm ERR! argv "/home/ole/.nvm/versions/v6.4.0/bin/node" "/home/ole/.nvm/versions/v6.4.0/bin/npm" "publish" "--access" "public"
npm ERR! node v6.4.0
npm ERR! npm v3.10.3
npm ERR! code E404
npm ERR! 404 Not found : #supericium/pli
npm ERR! 404
npm ERR! 404 '#supericium/pli' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! /home/ole/Sandbox/pli/npm-debug.log
I tried updating both NodeJS and NPM to make sure that I have the latest version, which are:
ole#MKI:~/Sandbox/pli$ node --version
v6.4.0
ole#MKI:~/Sandbox/pli$ npm --version
3.10.3
Thoughts?
You need to have registered "supericium" (npm adduser) as a username at the registry and be logged in (npm login) to publish under that scope.
https://docs.npmjs.com/getting-started/publishing-npm-packages
https://docs.npmjs.com/getting-started/scoped-packages
It's solved by npm login in my case, the error message is misleading
Came across this same error, and my issue was that the package was somehow set to "Read" access only. So I have to go to the NPM and update the package to "Read/Write" access:
1.
2.
Nothing worked for me, except logging in again:
npm login
Hope this helps me or someone else in the future!
You could also get this error when you change your password to NPM but you do not logout/login via your CLI. Using npm logout and then npm login worked for me.
in my case I had to verify the email address. even when npm whoami was telling me I was logged in fine.
In my case, I got this message because the token that I was using had been revoked. I fixed it by:
Generating a new access token in my npm account.
Modifying the line: export NPM_TOKEN="<token>" in my .zshrc (or .bashrc) file
Entering source ~/.zshrc in the terminal.
I just logged in to npm by using npm adduser command and it worked fine.
In my case, I was missing the repository field in the package.json of my new package that I was trying to publish.
"repository": "git://github.com/your-org/your-repo-name.git"
https://docs.npmjs.com/files/package.json#repository
This error appeared for me in two cases:
When I wasn't logged in. You can check whether you are logged in or not by npm whoami, then if not logged in npm login.
When I didn't have right to publish to the repository. In this case make sure you are added to the organization which owns the repo.
in my case i noticed that my npm account username in npm website is different than my npm normal user name. When i try to publish in console by login with normal username gave me this error.
publish Failed PUT 404 npm ERR! code E404 npm ERR! 404 User not found
But after login to console with account name it has published successfully
Once you successfully publish the package you may experience when you try to npm install:
npm ERR! code E404
npm ERR! 404 Not Found: #xxx/yyy#latest
or something similar, regardless if you npm publish was successful. In this case make sure your {main: 'file.js'} in packages.json is there.
Ideally, you can call it index.js if you wish to leech directly from the package so you don't get things like import * from '#xxx/yyy/file'.
In my case, I believe I enabled 2FA on npmjs.com so the publish token used in CD didn't work (should have thrown 401, but got 404).
Generating a new automation token on npmjs.com and updating the secret on my CD (GitHub actions) solved it.
I encountered the same problem but I successfully resolved it by uninstalling the LTS version, then installing Current version along with yarn.
Just adding my two cents to the possible solutions
I was getting this error in a CI workflow, so no interactive login or things related.
Existing packages were working correctly, but adding a new one wasn't, I was getting a 404. I realized that it should be something related to the new package itself, not the CI environment, and it was.
The new package was missing two fields on its package.json, the repository and publishConfig fields.
Adding these two fields, it worked correctly (note that repository field is used in its expanded form, with the directory property)
"repository": {
"type": "git",
"url": "ssh://git#github.com/__user__/__repo-name__.git",
"directory": "packages/__new-package-name__"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
}
For me the fix seemed to be making a new "team" in the organisation and assigning myself and my package to this.
My guess is that my NPM organisation requires users to have 2FA on and two users assigned to the 'developers' group didn't have this on.
In my case i accidentally typed https://registry.npmjs.org instead of https://registry.npmjs.com (.org vs .com)
In my case the problem was completely different.
I had to replace:
npm publish FOLDERNAME
with simply:
cd FOLDERNAME && npm publish
In my case I also had to manually specify the path of .npmrc using the --userconfig parameter:
cd myapp && npm publish -ddd --userconfig ../.npmrc
In my case, I had a typo when passing the otp param:
// Wrong:
npm publish --access public --opt 123456
// Correct:
npm publish --access public --otp 123456
Related
I'm trying to upload an npm package to a GitLab registry for the first time. I set the scope and the npm config entries according to the documentation, but when I execute npm publish, I get the following error:
npm notice Publishing to https://git.myorg.com/api/v4/projects/123/packages/npm/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://git.myorg.com/api/v4/projects/123/packages/npm/#myscope%2fmyproject
npm ERR! 404
npm ERR! 404 '#myscope/myproject#1.0.0' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
So I try to publish it, and the error says it doesn't exist and that I should publish it...what?!
From the last two lines it looks like the error is meant for an installation failure, but I have definitely used npm publish. Also, in the PUT command, the final slash between scope and project name is replaced with %2f. No idea why that happened and why it happened nowhere else, but maybe that is a symptom of the underlying issue?
Ok, it was my own fault. When executing npm config set #foo:registry https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/, I put in the group ID instead of the project ID in the place of <your_project_id>. We use the group only for the package registry project, so I got them confused.
npm ERR! code E404
npm ERR! 404 Not Found - GET http://registry.npmjs.org/#office%2fintegration-sdk - Not found
npm ERR! 404
npm ERR! 404 '#office/integration-sdk#*' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
We have private bitbucket repo, with package code, that we want to make npm private package out of it.
I've managed to publish it thru CLI with npm publish, and with the bitbucket pipeline.
And it can be installed fine, as long as i am logged in with npm login.
But we want to be able to install it without logging to npm(when deployed etc..), and i thought NPM_TOKEN is there for those reasons.
I've tried buncha stuff in .npmrc file, mostly like:
#office:registry=https://registry.npmjs.org/:_authToken=<'read/publish token from npm'>
Steps:
npm publish
check npm - package looks good, updated, etc..
run install command - npm i #office/integration-sdk
Fails with either 404(most of the time), and with 405 Method not Allowed when i have #office:registry=https://registry.npmjs.org/#office.
One thing that might be causing this.. We only have user account on npm i guess, it is Pro account with private packages thing. But we didn't create organization. Could that be a problem, i mean it can be published, and installed when logged in, and also public packages can be installed just fine when not logged in.
Current Behavior:
I am attempting to configure a project to install dependencies from NPM. I will be publishing the project to GitHub Packages as a private package. If I use this syntax in my project's .npmrc:
#my-org:registry=https://npm.pkg.github.com/
I can install dependencies from NPM using npm install on my local machine. However, I cannot publish to GitHub Packages using npm publish. NPM informs me that I'm not authenticated. If I use this syntax in my project's .npmrc:
registry=https://npm.pkg.github.com/my-org/
I can publish using npm publish, but I cannot install dependencies with npm install. NPM informs me that it's trying to install dependencies from GitHub Packages, rather than NPM.
Expected Behavior:
Based on my reading, both syntaxes should be compatible with npm install and npm publish. However, it appears I can only use one or the other, based on my intended use.
Steps To Reproduce:
Install Node v15.7.0 and NPM 7.4.3 via nvm.
Log in to GitHub Packages with the command:
npm login --scope=#my-org --registry=https://npm.pkg.github.com
Check our ~/.npmrc file in our home folder. It should read:
#my-org:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=<auth-token-used-for-login>
Create project with the following package.json:
{
"name": "#my-org/my-package",
"description": "A test.",
"version": "1.0.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/my-org/my-package.git"
},
"keywords": ["example"],
"author": "Me",
"license": "ISC",
"bugs": {
"url": "https://github.com/my-org/my-package/issues"
},
"homepage": "https://github.com/my-org/my-package",
"dependencies": {
"bootstrap": "^4.5.2"
}
}
Add the following .npmrc to our project:
#my-org:registry=https://npm.pkg.github.com/
Run npm install. Installation should succeed.
Run npm publish. Receive the following error:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/my-user/.npm/_logs/2021-01-28T20_19_55_974Z-debug.log
Change the project .npmrc to:
registry=https://npm.pkg.github.com/my-org/
Run npm publish. Publishing should succeed.
rm -rf node_modules/ package-lock.json in project.
Run npm install. Receive following error:
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/my-user/.npm/_logs/2021-01-28T20_38_20_711Z-debug.log
Environment:
OS:
MacOS Catalina 10.15.7
MacOS Big Sur 11.1
Node: 15.7.0
npm: 7.4.3
Things I've tried
Using publishConfig
Unfortunately, publishConfig doesn't fix the issue. It also doesn't address that the two .npmrc syntaxes produce different results.
Project .npmrc authToken
NPM's documentation states there is no need to include the authToken in the project .npmrc. Authenticating with npm login and storing the authToken in the global ~/.npmrc should be sufficient.
Workaround
Using the --registry command line flag
I've found a workaround until the NPM bug affecting this issue is resolved. When using the following project .npmrc syntax:
#my-org:registry=https://npm.pkg.github.com/
If I run npm publish --registry=https://npm.pkg.github.com/, I can publish successfully. In addition, I can install dependencies without issue.
Update (May 30, 2021)
This has been fixed in NPM 7.5.3 and above.
Original answer (April 20, 2021)
This has been confirmed as a bug on NPM 7.x. The team is currently working to fix the bug with their GitHub Pull Request #2602. Until this bug fix has been released, the best recommendation is to do one of the workarounds listed below.
Workaround 1: --registry command line flag
When running npm publish, add the --registry flag. This flag enables developers to specify the registry they're aiming to publish to, overriding .npmrc or package.json configurations. For the example listed in my question, the project .npmrc should contain:
#my-org:registry=https://npm.pkg.github.com/
Publishing will succeed when initiated by running:
npm publish --registry=https://npm.pkg.github.com/
Workaround 2: Dummy token for default registry
According to npm developer wraithgar's comment on this bug's GitHub issue, you can use a dummy token for the default NPM registry to workaround this issue. In our project's .npmrc, add the following line:
//registry.npmjs.org/:_authToken=dummy
The full project .npmrc should contain:
//registry.npmjs.org/:_authToken=dummy
#my-org:registry=https://npm.pkg.github.com/
In the question, neither of the project .npmrc syntax's we've tried to use has designated a registry, because NPM's documentation states we don't have to. The documentation states that it'll check our global ~/.npmrc if there isn't one in our project .npmrc. The bug in NPM is causing NPM to check if a project .npmrc has designated a registry before it'll attempt to authenticate. In wraithgar's own words:
What happens is that currently the cli is only looking for your configured "registry" setting when seeing if you have logged in. So the temporary solution is either to override that setting (as you were doing by passing --registry), OR to add a token for the default (npm) registry so that the check for a token does not fail. The check is only looking for the presence of a token in the config, it's not validating it (that of course will happen when and if it is used during an actual request), so putting a dummy value in will stop the error until that PR lands.
After adding the dummy token, running npm publish and npm install should both succeed.
I had the same error. First thing I have fixed was npm version to > 7.5.3 as suggested in accepted answer, but no luck, same error:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`
After trying all of advised workarounds it still was giving the same output. Finally I found the reason: I forgot to add the scope in the package.json "name" property, so problem was solved by changing
{
"name": "my-package",
...
to
{
"name": "#my-org/my-package",
...
I found 2 problems in steps from 1 to 7.
in step 4, did you try to add the field below in the package.json
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
}
in .npmrc in step 5, I didn't see //npm.pkg.github.com/:_authToken=<auth-token-used-for-login>, remember // is not the comment. ; or # are for comments. https://docs.npmjs.com/cli/v6/configuring-npm/npmrc#comments
I installed node on my Mac OS Sierra. I use Windows at my work so there I have a .npmrc file in the node folder but I don't seem to find that in mac.
The problem is I want to add a registry of the format
"scope=rohit-project#rohit-aquila:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=some-token"
How do I add it so that I can install the dependencies and modules for my project by running npm install on MAC OS Sierra.
I created a .npmrc file simply and added the above code...and therefater running npm install I get the following error
rohitsrivastava$ npm install
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! code E404
npm ERR! 404 Not found : #rohit-project/notes
npm ERR! 404
npm ERR! 404 '#rohit-project/notes' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of '#rohit-project/mega'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
There are a few different points here:
Where is the .npmrc file created.
How can you download private packages
Running npm config ls -l will show you all the implicit settings for npm, including what it thinks is the right place to put the .npmrc (the field userconfig), as this is environment/operating system dependant. But if you have never logged in (using npm login) it will be empty. Simply log in to create it.
To just output the path prop, issue npm config get userconfig.
Another thing is #2 - downloading private packages. You can actually do that by putting a .npmrc file in the NPM package's root. It will then be used by NPM when authenticating. It also supports variable interpolation from your shell so you could do stuff like this:
; Get the auth token to use for fetching private packages from our private scope
; see http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
; and also https://docs.npmjs.com/files/npmrc
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
Pointers
http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
https://docs.npmjs.com/files/npmrc
In MacOS Catalina 10.15.5 the .npmrc file path can be found at
/Users/<user-name>/.npmrc
Open in it in (for first time users, create a new file) any editor and copy-paste your token. Save it.
You are ready to go.
Note:
As mentioned by #oligofren, the command npm config ls -l will npm configurations. You will get the .npmrc file from config parameter userconfig
This issue is because of you having some local or private packages.
For accessing those packages you have to create .npmrc file for this issue. Just refer the following link for your solution. https://nodesource.com/blog/configuring-your-npmrc-for-an-optimal-node-js-environment
In my case, updating my npm version helped me. So just to be sure, make sure your npm is up to date.
npm install -g npm#latest
Assuming you are using VSTS run vsts-npm-auth -config .npmrc to generate new .npmrc file with the auth token
github: https://github.com/Sly777/React-UI-Debugger
travis CI: https://travis-ci.org/Sly777/React-UI-Debugger
semantic-release: ^6.3.2
basically i'm trying to publish package as first release to public by using semantic-release & travis CI but it doesn't work. I'm getting these errors below.
it's giving error on travis CI
/home/travis/build/Sly777/React-UI-Debugger/node_modules/#semantic-release/last-release-npm/dist/index.js:29
var version = data['dist-tags'][npm.tag];
^
TypeError: Cannot read property 'latest' of undefined
after i got this error, i tried to run npm dist-tag ls on local but that time i got error like this
npm ERR! dist-tag ls Couldn't get dist-tag data for react-ui-debugger
npm ERR! Darwin 16.3.0
npm ERR! argv "/Users/xxxx/.nvm/versions/node/v6.9.1/bin/node" "/Users/xxxx/.nvm/versions/node/v6.9.1/bin/npm" "dist-tag" "ls"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code E403
npm ERR! Registry returned 403 for GET on https://registry.npmjs.org/-/package/react-ui-debugger/dist-tags
npm ERR!
package.json
{
"name": "react-ui-debugger",
"version": "0.0.0-development"
}
Also i pushed latest tag on github.
What's your opinion? What do you suggest?
After tried many times, I found the solution for this (actually, it's not entirely solution). For your first release of your package, you need to release your package without using "semantic-release". With "semantic-release", I don't know why (i didn't get any answer from their team) but it's not working for the first release.
There might already be a package in the npm registry with the same name. The repo, with which I encountered the same issue, that you reported was already claimed once by someone else and it is currently unpublished.
To check this, simply open this link your browser:
https://registry.npmjs.org/<your package name>
(be sure to type your package name with lowecase letters all the way)
I have also added this info to your github issue page: https://github.com/semantic-release/semantic-release/issues/352
My suggestion is either create a new repo with a different name, or do a manual publish to claim the registry entry as yours.