Published a NPM package to Azure Artifacts but getting this error while installing - npm

F:\angular library\sampleangular>npm install examplepackage#0.0.1
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/examplepackage- Not found
npm ERR! 404
npm ERR! 404 'examplepackage#0.0.1' 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! A complete log of this run can be found in:
npm ERR! C:\Users\jack\AppData\Roaming\npm-cache_logs\2020-03-03T06_07_13_338Z-debug.log

We have the same error (E404). The root cause turned out, is because we have multiple registry sources. One is our own registry and the other is public registry (registry.npmjs.org)
To resolve this, we added both registries in the .npmrc file (can be in either user's .npmrc or the project .npmrc).
We append the following lines in the .npmrc file.
#contosoPrivateFeed:registry=https://contoso.pkgs.visualstudio.com/_packaging/Contoso.Feed/npm/registry/
registry=https://registry.npmjs.org
Also worth to mention, we don't have Upstream setup in our Azure DevOps feed.
Specifying multiple registries allow npm commands to use the registries. Thus, no need to setup Upstream sources.

After some tests, we think your issue may be related to the UpStream source in Azure devops feed settings.
Here's some info when I do the test:
nest is package from default npm packages. When i deleted the npm upstream source, I got the same error when running command npm install nest. After that I added the NPM public source(npmjs) as one upstream sources in feed settings, then it worked when I ran the command the second time.
So you need to add npmjs as Upstream source of your current feed. Hope it helps :)

Related

How to resolve err code 403 Forbidden in npm install?

I'm trying to run npm install in a public repository. I’ve cloned it to my PC but it throws me this error.
I’ve tried verifying my npm account, and disabling my security/firewalls.
I dont know how to solve it!
$ npm install
npm ERR! code E403
npm ERR! 403 403 Forbidden - GET <url>
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\...
Nothing to worry about.
Probably, there is a security policy for different libraries (in case it is corporate project).
In this case you need to investigate your issue to someone in your company.
Another case can be with package-lock.json
Just open lock file and try to find something similar to received URL.
Try to delete lock file and after that run npm install
I had a similar error and here is what helped me:
npm config set registry https://registry.npmjs.org/
It sets the npm registry to default. More info here: https://docs.npmjs.com/cli/v8/using-npm/registry
Run this to check your current registry value:
npm config list
If a change of the registry doesn't help, you can check what npm username is in use by running:
npm whoami
If it is not the one that has related permissions for the package to be installed then log in with related credentials by running:
npm login

NPM 8 workspaces - Install one package as the dependency for another package in monorepo

Say I have the following structure
packages
- #my-scope/packageA
- #my-scope/packageB
- #my-scope/packageC
Let's say I want to install packageA as a dependency of packageB. With NPM 8 workspaces I would think this ought to do it:
npm install #my-scope/packageA --workspace=#my-scope/packageB
Instead I get this:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#my-scope%2fpackageA - Not found
npm ERR! 404
npm ERR! 404 '#my-scope/packageA#*' 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.
Clearly it is trying to get it from the registry (and no, I haven't published yet, not ready) but I want it to recognize that this dependency is in my project as a workspace. Anyone know why this might be happening? I haven't found many good resources explaining how to install dependencies from inside your monorepo (I don't even know what those are called...).
The problem you are facing has been reported as a bug: https://github.com/npm/cli/issues/3637
It has been marked as fixed.
Please try to install the latest version of npm (8.8.0 as of this writing) and see if your problem has been resolved.

Unable to install published GitLab private package

I successfully published a package in a private GitLab repository of my organisation. In my global and local .npmrc configuration file I have the following:
# Set URL for your scoped packages.
#<main-package-name>:registry=https://gitlab.<my-organisation-domain>/api/v4/packages/npm/
'//gitlab.<my-organisation-domain>/api/v4/packages/npm/:_authToken'="<my-token>"
'//gitlab.<my-organisation-domain>/api/v4/projects/<my-project-id>/packages/npm/:_authToken'="<my-token>"
In the package.json file I have the following properties:
"publishConfig": {
"#<main-package-name>:registry": "https://gitlab.<my-organisation-domain>/api/v4/projects/<my-package-id>/packages/npm/"
},
"name": "#<main-package-name>/<library-name>",
...
On the GitLab Package and Registry project's page, it says the following:
Installation
npm i #<main-package-name>/<library-name>
Registry setup
echo #<main-package-name>:registry=https://gitlab.<my-organisation-domain>/api/v4/packages/npm/ >> .npmrc
I added "#<main-package-name>/<library-name>": "~0.0.11" to the project's package.json, but when I try and run npm install I get:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/#<main-package-name>/<library-name> - Not found
npm ERR! 404
npm ERR! 404 '#<main-package-name>/<library-name>#~0.0.11' 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! A complete log of this run can be found in:
npm ERR! /path/to/log
It seems it's trying to fetch the package from npmjs instead of the specified GitLab registry. Can anyone help?
Removing the local .npmrc in the project where I was requesting the package and keeping just the global one in my home solved the issue, for some very weird reason.
Maybe is a problem of encoded url, check if you not have %2f in the url which not found between your scope and package name
For me it was a problem of my virtual host configuration of gitlab
I have add the following lines and that fix my problem:
AllowEncodedSlashes NoDecode
AllowEncodedSlashes On

Issue with Publishing NPM Package (org.couchdb.user:USERNAME' is not in the npm registry)

Issue:
I'm trying to publish my npm package https://www.npmjs.com/package/react-native-ultimate-modal-picker and it's coming up with the error. It's been 9 months since I last have made a publish and I just updated a ton of code and files. I also set the publishing from NPM to GitHub, but I think I reverted those changes?
Question:
Why am I getting the errors below?
How can I make sure that the npm package is published to https://www.npmjs.com/package/react-native-ultimate-modal-picker?
Errors:
org.couchdb.user:jefelewis' is not in the npm registry.
This package name is not valid, because
npm ERR! 404 1. name can only contain URL-friendly characters
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`
Process:
npm login
Enter login info (Username: jefelewis)
org.couchdb.user:jefelewis is not in the npm registry.
The issue is that my username is jefelewis (https://www.npmjs.com/~jefelewis)
Update:
This was fixed by using npm config set registry https://registry.npmjs.org/ in the terminal

Kendo Angular 2 controls not in npm registry on XAML build

Started using angular2 with .NET Core and I'm trying to get continuous integration going on the build servers.
We are running TFS2013 so it's a XAML build definition. Since I don't want the node_modules folder checked in to source control, I'm attempting to run npm install in a powershell script before the build starts.
When I do this I get the following
npm ERR! 404 Not found : #progress/kendo-angular-dropdowns npm ERR!
404 npm ERR! 404 '#progress/kendo-angular-dropdowns' 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 'angular2-webpack' npm ERR! 404 npm ERR! 404 Note that
you can also install from a npm ERR! 404 tarball, folder, http url,
or git url.
On Telerik's site they say you need to enable the NPM registry by running this in the console
npm login --registry=https://registry.npm.telerik.com/ --scope=#progress
This requires you to provide account details though.
I've done this on the build server and I'm able to run npm install successfully from the command line, but no such luck when attempting it from the powershell script in MSBuild.
Any help would be greatly appreciated.
The error is most likely caused by the registry not available to the build script.
Make sure that there is a .npmrc file that specifies the registry and the auth token, not unlike this:
#progress:registry=https://registry.npm.telerik.com/
//registry.npm.telerik.com/:_authToken=long_secret_token_here
... and that the file is honored by MsBuild.