78

Using the command prompt, I am trying to install angular CLI and it fails. I have npm version 5.5.1 and node version v8.9.1. I am trying to install angular cli using the command

npm install -g @angular/cli@latest

and it fails with the error:

npm ERR! code E404 npm ERR! 404 Not Found: @angular/cli@latest npm ERR! A complete log of this run can be found in:

I look at the log file and I see its trying to fetch the package from a location that doesn't exist. Not sure from where it gets pulled. How do I fix this location path and install angular cli. Same happens when I try to install typescript or any other npm package. all of them try to install from the location mentioned below and it fails with 404

8 http fetch GET 404 
       http://nuget.feed.xyz.corp:8729/npm/FeedNPM/@angular%2fcli 109ms
9 silly fetchPackageMetaData error for @angular/cli@latest 404 Not Found: 
     @angular/cli@latest
10 verbose stack Error: 404 Not Found: @angular/cli@latest
3
  • 1
    What's your question? It looks like @angular/cli doesn't exist. Commented Nov 27, 2017 at 21:37
  • 3
    See this question's top answer, and use the default npm registry location: stackoverflow.com/questions/22385092/… . Registry: registry.npmjs.org Commented Nov 27, 2017 at 21:51
  • 1
    Yep, That was it. Can't thank you enough!! Your answer made my day! Commented Nov 27, 2017 at 22:08

21 Answers 21

98
npm config set registry http://registry.npmjs.org

NPM registry documentation

Sign up to request clarification or add additional context in comments.

4 Comments

Should be the accepted answer - Weird took me a while to find through searches thanks
Should I use http or https?
Looks lie it's redirecting to https so it doesn't matter
It doesn't redirect to HTTP for me - showing a 426 upgrade required in the terminal -and this does not fix the issue.
23

Try first this commands (in windows run as administrator)

npm config set registry http://registry.npmjs.org
npm install -g @angular/cli

if still not working let's update NPM and nodejs by running this commands

npm -g install npm
npm cache clean -f
npm install -g n

then try to run

npm install -g @angular/cli

This should solve this problem

2 Comments

When I do the above options, I got rollbackFailedOptional and ETIMEOUT later. Any advice will be greatly appreciated.
in which OS? if you are using windows just then you can try to unintall and try again may be this works.
16

in my case it was .npmrc file in my project dir, which kept overwriting my global registry url. As soon as I deleted it, I could finally use npm install

2 Comments

Same here. Had to delete .npmrc (was trying to install private package) , then do npm install and once it worked I restored the .npmrc back to the project
I had an issue with my .npmrc file. There were some mandatory entries that I had missed.
6

Add a .npmrc file in the root of the project. .npmrc will look like below -

@xy:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/ @xy-app:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/

And Delete all the field eg - email , auth etc. Find out what is the registry url of your application and put it into the registry.

Then run command - npm install And it will work.

Comments

4

It was giving the same error for me when I use office network/vpn as they have 'umbrella' DNS security shield. To solve this issue, connect to personal network and type the below commands:

    npm config set registry http://registry.npmjs.org
    npm install -g @angular/cli

Comments

4

I spent hours on this.

I had to follow the below steps to get it to work (mac).

Delete my LOCAL (not project) .npmrc by running:

rm /Users/<NAME>/.npmrc

Then set the registry:

npm config set registry https://registry.npmjs.org/

Then follow the steps for logging in to npm:

npm login

Check what's in your config list by running:

npm config list

It should look like this:

//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org/"

Hope it works for you too.

Comments

3

Alternative, another option to avoid 404 npm error

check if your terminal is in the root directory, if not your npm scripts will not execute because it will not be able to see the package.json

Comments

3

When I looked for .npmrc in home folder I couldn’t find it.

But and after running:

$ npm config set registry http://registry.npmjs.org

This fixed my problem.

Comments

2

I had same problem with a private package. Need to:

  • npm adduser
  • npm login

Comments

1

Uninstall NPM & nodejs and install the right way NPM (Ubuntu)

sudo with npm is not recommended

To Uninstall

sudo apt-get remove nodejs
sudo apt-get remove npm

or

sudo apt-get purge nodejs
  1. Followed by proper installation

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

  1. To confirm open a new terminal run:

$ command -v nvm

  1. Latest LTS release of NodeJS:

$ nvm install --lts

  1. Set default environment

$ nvm alias default lts/*

Comments

0
  1. change your access level to public. type this in the terminal
npm --access=public
  1. install your angular.
sudo npm install @ngular/cli

Comments

0

In my case, that's a typo error:
change trct-js-sdk to trtc-js-sdk saved my life.

Comments

0

My solution was as follows because I had a dependency on a private package. If you see the dependency in package.json defined in the format @scope/package, then @scope tells you that it's a scoped package that might be private.

  1. Get the private package owner to grant you access to the package
  2. Upgrade npm
  3. Upgrade node
  4. Add registry using HTTPS (not HTTP), e.g. npm config set registry https://registry.npmjs.org
  5. Do "npm login"
  6. Now run the build

Comments

0

Worked for me

I got

error 404 'dotnev@*' is not in this registry.

Deleted .npmrc file in 2 folders back over my project root and then in the project root folder typed:

npm i dotenv

copied from: https://www.npmjs.com/package/dotenv

Comments

0

Just run sudo npm config set registry http://registry.npmjs.org and then update your npm.

Comments

0

I had the same problem. What did I do?

First I deleted the .npmrc file in home/user

  • ls -a
  • sudo rm .npmrc

Then I downgraded my npm to a lower version

Then in my application I deleted the node_module package and runned the npm install.

Comments

0

The top most answer is correct and will solve your issue with 404 error. Just wanted to add to this answer that helped me resolve the issue in my case.

Post setting the registry,

Do a npm cache clean and restart your system. Now, try re-installing the package, it should work.

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
0

if private repo running behind reverse proxy server, and using proxypass to redirect request from apache to nexus repo. then special character in url may be because of Encoding of slash on apache server.

set below parameter to fix on apache.

AllowEncodedSlashes NoDecode

Comments

0

Verify that the npm is pointing in the correct place:

npm config get registry

my mistake is that it was pointing to "http" not "https"

so just reset the config:

npm config set registry https://registry.npmjs.org/

Comments

-2

It is an network error , check your network connection and try to install it again.

Comments

-2

the only command line "npm -g install npm" solved the issue for me! the following link can be helpful to dig deep for a better understanding. Thanks a lot.

1 Comment

"The following link"? Where?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.