node.js 清除缓存后 npm 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20259492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:23:17  来源:igfitidea点击:

npm not working after clearing cache

node.jsnpm

提问by user3044659

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.

npm 工作正常。清除缓存后,它不起作用。下面的错误日志表明互联网连接有问题,但互联网连接很好。这个问题不仅发生在 bower 上,也发生在任何模块上。

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

回答by ASHISH RANJAN

This worked for me:

这对我有用:

npm cache clean --force 

回答by Per Quested Aronsson

回答by RBZ

"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@5 开始,npm 缓存会从损坏问题中自我修复,并且从缓存中提取的数据保证是有效的。如果你想确保一切都是一致的,请使用

npm cache verify

instead."

反而。”

回答by AAshish jha

try this one npm cache clean --forceafter that run npm cache verify

npm cache clean --force跑完后 试试这个 npm cache verify

回答by Masoud Bimar

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 说 npm 上的新版本(> 5)具有自我修复机制,我需要做的每件事来检查 npm 都是使用 verify

npm cache verify

npm message :

npm 消息:

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 使用这个:

npm cache clean --force

回答by Saurabh Agrawal

Try npm cache clean --forceif it doesn't work then manually delete %appdata%\npm-cachefolder.

尝试npm cache clean --force如果它不起作用然后手动删除%appdata%\npm-cache文件夹。

It worked for me.

它对我有用。

回答by abid

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

尝试npm cache clean --force如果它不起作用然后手动删除 %appdata%\npm-cache 文件夹。

and install npm install npm@latest -g

并安装 npm install npm@latest -g

It worked for me.

它对我有用。

visit this link

访问此链接

回答by mEnE

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

[email protected] 支持的命令是 npm cache verify

回答by Maharaj Santhir

Environment path may have been removed.

环境路径可能已被删除。

Check it by typing,

通过键入检查它,

npm config get prefix

npm config get prefix

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

这必须是找到 npm 二进制文件的位置。

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

在 windows 中,c:/users/username/AppData/Roaming/npm是找到它们的地方。

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)

(控制面板 -> 搜索“环境变量”并单击具有该名称的按钮 -> 编辑路径 -> 添加上述位置)

回答by Andre Evangelista

I had to install the latest version of NodeJS. That worked out for me.

我必须安装最新版本的 NodeJS。这对我有用。