user3044659
user3044659

Reputation: 1869

npm not working after clearing cache

Before clearing cache

npm cache clear

npm is working fine. After clearing cache, it is not working. The error log below suggest problem with internet connectivity but internet connection is just fine. This problem does not only happen for bower but for any modules.

Here's the output of process:

> sudo npm install -g bower Password: npm http GET
> https://registry.npmjs.org/bower npm http GET
> https://registry.npmjs.org/bower npm http GET
> https://registry.npmjs.org/bower npm ERR! network connect ETIMEDOUT
> npm ERR! network This is most likely not a problem with npm itself npm
> ERR! network and is related to network connectivity. npm ERR! network
> In most cases you are behind a proxy or have bad network settings. npm
> ERR! network npm ERR! network If you are behind a proxy, please make
> sure that the npm ERR! network 'proxy' config is set properly.  See:
> 'npm help config'
> 
> npm ERR! System Darwin 12.5.0 npm ERR! command
> "/usr/local/Cellar/node/0.10.16/bin/node" "/usr/local/bin/npm"
> "install" "-g" "bower" npm ERR! cwd /Users/username npm ERR!
> node -v v0.10.16 npm ERR! npm -v 1.3.8 npm ERR! syscall connect npm
> ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! npm ERR!
> Additional logging details can be found in: npm ERR!    
> /Users/username/npm-debug.log npm ERR! not ok code 0

Upvotes: 176

Views: 648666

Answers (13)

mdimai666
mdimai666

Reputation: 787

rm C:\Users\<User>\AppData\Local\npm-cache\

Upvotes: 1

sumith deepan
sumith deepan

Reputation: 106

npm install --cache /tmp/empty-cache

Upvotes: 0

Yasir
Yasir

Reputation: 585

npm cache clean --force 

or

npm cache clean 

after that run

npm cache verify

Upvotes: 0

Saurabh Agrawal
Saurabh Agrawal

Reputation: 7739

Try npm cache clean --force if it doesn't work then manually delete %appdata%\npm-cache folder.

Upvotes: 8

Saad Abbasi
Saad Abbasi

Reputation: 853

I solved this issue by running cmd as an administrator. before that, I was trying to run in vs code.

run it in Power Shell or Cmd with administrative privilege. I hope that it will help.

npm install –g @angular/cli@latest

Upvotes: 0

user12910330
user12910330

Reputation:

Try npm cache clean --force if it doesn't work then manually delete %appdata%\npm-cache folder.

and install npm install npm@latest -g

It worked for me.

visit this link

Upvotes: 19

Per Quested Aronsson
Per Quested Aronsson

Reputation: 12110

It should be

npm cache clean  

See https://docs.npmjs.com/cli/cache.html

Upvotes: 149

Masoud Bimar
Masoud Bimar

Reputation: 7791

I try to

npm cache clean 

But npm said newer version on npm (> 5) has self healing Mechanism and every thing i need to do for checking npm is use verify

npm cache verify

npm message :

The npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. 

If you want to make sure everything is consistent, use 'npm cache verify' instead.

but for forcing npm use this:

npm cache clean --force

Upvotes: 14

RBZ
RBZ

Reputation: 2074

"As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use

npm cache verify

instead."

Upvotes: 77

menepet
menepet

Reputation: 882

at [email protected] the command that is been supported is npm cache verify

Upvotes: 1

AAshish jha
AAshish jha

Reputation: 952

try this one npm cache clean --force after that run npm cache verify

Upvotes: 33

ASHISH R
ASHISH R

Reputation: 4189

This worked for me:

npm cache clean --force 

Upvotes: 223

Maharaj Santhir
Maharaj Santhir

Reputation: 49

Environment path may have been removed.

Check it by typing,

npm config get prefix

This must be the location where the npm binaries are found.

In windows, c:/users/username/AppData/Roaming/npm is the place where they are found.

Add this location to the environment variable. It should work fine.

(Control Panel -> Search for 'Environment Variables' and click on a button with that name -> edit Path -> add the above location)

Upvotes: 3

Related Questions