如何在Windows上更改npm的缓存路径(或完全禁用缓存)? [英] How can I change the cache path for npm (or completely disable the cache) on Windows?

查看:361
本文介绍了如何在Windows上更改npm的缓存路径(或完全禁用缓存)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 7 x64开发计算机上以手动方式安装了Node.js:

I've installed Node.js on my Windows 7 x64 development machine, the manual way:

mkdir C:\Devel\nodejs
cd C:\Devel\nodejs
set NODE_PATH=%CD%
setx /M PATH "%PATH%;%NODE_PATH%"
setx /M NODE_PATH "%NODE_PATH%\node_modules"

我将主节点x64二进制文件

I've placed the main node x64 binary along with npm package manager in C:\Devel\nodejs. Works like a charm and I can update the main binary without dealing with the installer.

我无法解决的唯一问题是移动缓存文件夹.当我安装本地软件包时:

The only problem I can't solve is moving the cache folder. When I install a local package:

npm install express

...缓存位于%APP_DATA%\npm-cache文件夹下.我想将其更改为:

... cache is placed under %APP_DATA%\npm-cache folder. I'd like to change it to:

C:\Devel\nodejs\npm-cache

如何更改npm缓存文件夹或完全禁用它?

How can I change the npm cache folder, or disable it completely?

推荐答案

您可以使用npm命令行更改npm缓存文件夹. (请参阅: https://docs.npmjs.com/misc/config ,更具体地说是 https://docs.npmjs.com/misc/config#cache )

You can change npm cache folder using the npm command line. (see : https://docs.npmjs.com/misc/config and more specifically https://docs.npmjs.com/misc/config#cache)

所以您可能想尝试以下命令:

So you might want to try this command :

> npm config set cache C:\Devel\nodejs\npm-cache --global 

这篇关于如何在Windows上更改npm的缓存路径(或完全禁用缓存)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆