npm error 401 unauthorized with #scope/packagename. - node.js

Trying to do npm install for a package fails when any of the dependencies have a scoped public package e.g. #babel/generator with a 401 Unauthorized
or something like
error Couldn't find package "#babel/generator" on the "npm" registry.

In my case,
I tried an npm logout which might have cleared/reset local storage/session
info related to my npm login.
After that I am able to download/install publicly scoped packages normally.

Credit to Wes Bos here: https://twitter.com/wesbos/status/1067822624561143809
Logging into npm with npm login resolved this for me.

Related

ERROR: npm ERR! code EOVERRIDE npm ERR! Override for axios#^1.2.0 conflicts with direct dependency

I have built an Azure chatbot that works fine in Bot Emulator locally but fails when I upload it to Azure. I get the following error:
npm ERR! code EOVERRIDE
npm ERR! Override for axios#^1.2.0 conflicts with direct dependency
I'm not entirely sure what this means. Does anyone know how to get around this?
I have tried to update the Axios package in both package-lock and package json files and nothing has worked
This error is due to the impact of packages in npm library related to axios package. We need to override the package manually using the below code block.
npm install axios-method-override
import axiosMethodOverride from 'axios-method-override';
axiosMethodOverride(axios);
const instance = axios.create();
axiosMethodOverride(instance);
we need to use override patch of HTTP, PUT, DELETE in this implementation.

How to make npm install a scoped package without scope name?

I'm trying to install some packages from Azure Artifacts Feed which was set up by my organization. I still need other external packages in https://registry.npmjs.org/. Although they have configured NPM as upstream source for feed, my 'Reader' permission doesn't allow me to add new packages. So I can only use NPM scopes to install private packages from a scope registry and public package from official registry. But I cannot install private packages simply with scope name.
I've config my user's .npmrc, get authentication using "vsts-npm-auth". It looks like this now:
# $HOME\.npmrc
proxy=http://my-enterprise-proxy.com
noproxy[]=blah-blah-blah
strict-ssl=false
registry=https://registry.npmjs.org/
#feed-scope:registry:=https://pkgs.dev.azure.com/[ORGANIZATION_NAME]/_packaging/[FEED_NAME]/npm/registry/
always-auth=true
//pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/npm/registry/:username=[ENTER_ANY_VALUE_BUT_NOT_AN_EMPTY_STRING]
//pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/npm/registry/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]
//pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/npm/registry/:email=npm requires email to be set but doesn't use the value
Now I try to execute:
npm install #feed-scope/package-needed
And I get:
npm ERR! code E404
npm ERR! 404 Not Found - GET pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/npm/registry/#my-scope%2fpackage-needed - The package '#my-scope/package-needed' was not found in feed '[FEED_NAME]'
npm ERR! 404
npm ERR! 404 '#my-scope/package-needed#*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
I've explored my org's feed, there is only a package named "package-needed". I doubt that the scope name I add to command just what the problem is. But I don't know how can I remove it.
PS: Please ignore those placeholders.
Unfortunately, that's not going to work. The scope is part of an npm package's name. You should work with the owners of your feed to get you the Collaborator role, which is the same as the Reader role plus the ability to use packages from upstreams which have not yet been saved to your feed. This is distinct from the Contributor role which also adds the ability to publish packages directly to the feed.

Private npm package fails to install with `npm ci` , but works with `npm i` why?

I have this package in my package.json: "uWebSockets.js": "github:uNetworking/uWebSockets.js#v18.9.0",
when trying to install this package within docker with npm i -> works
but with npm ci i get: npm ERR! Host key verification failed
First of all, would like to know what is the difference.
second, if I can get help on how to do CI within the docker file.
Thanks!!
A little bit late but here is a work around, taken from this github issue:
For the benefit of anyone looking for a workaround who struggled to
understand the conversation above, if you are installing something
from a public github repo and want to force https, this should work:
npm install git+https://<githubUsername>#github.com/<project>/<repo>.git
It potentially doesn't matter what github username you use, because
everyone can access public repos. The use of the username qualifies as
'auth' and therefore forces the protocol to be kept, as explained in
point 2 in #2610 (comment).

Due to a recent security incident, all user tokens have been invalidated

So I uninstalled the newer version of node that I had on my machine(v8.11.3) and then installed the earlier version v6.11.0 (because my project needs earlier version to do a grunt build). Now when I try to do npm install to restore the packages for my project it gives the following error.
Due to a recent security incident, all user tokens have been invalidated. Please see https://status.npmjs.org/incidents/dn7c1fgrr7ng for more details. To generate a new token, visit https://www.npmjs.com/settings/~/tokens or run npm login.
I tried doing a npm login to generate the token (token generation was successful) but throws same error when I try doing npm install the next time.
I got same issue last time.
Steps that I did:
I went to https://www.npmjs.com/settings/~/tokens and generate my token there.
Open new terminal
Execute npm whoami and check if your username appears. If not, do npm login
You should be able to npm install again
Hope it helps
I was facing the same problem as you.
If you save the npm token inside your project folder, delete the file and do npm install. Look for the file named .npmrc and delete that.
Let me know if that helps.
I was trying to install a package and I was getting the same error. After some time i realised that the package name which I was installing doesn't exists and npm was giving me this error.

Installation of a scoped package resolve in an E404

So I came across this problem when I am trying to install the request-promise module via npm.
It depends on a scoped package named #request/promise-core, and when I try to launch npm install request-promise from my project directory it returns me an error 404. This apparently it is a known issue, see: https://github.com/request/request-promise/issues/137, but none of the solutions works for me, probably due to a wrong implementation on my side.
What I tried so far:
configured npm config set "#request:registry" https://registry.npmjs.org/, but did not worked. Still returning E404
tried to manually install the package via github with npm install https://github.com/request/request-promise but no joy since it returns error: ENOEN when trying to open the request-promise-unpack/package.json file.
Probably I am missing some basic steps when trying to install the module, but I cannot figure out a different way of installing that module.
Any suggestions or alternatives is very appreciated.
I fixed with
npm install -g npm
in the terminal and then I could install it:
npm install --save request-promise

Resources