每当我在项目目录中运行npm install
时,npm就会获取并安装所有依赖项,即使它们已经安装在node_modules
中。 Npm不会从~/.npm/
中的缓存中安装,即使我的缓存中已经有大量的软件包。
以下是 有人知道为什么npm坚持一遍又一遍地获取新包吗?npm config ls -l
的; cli configs
long = true
registry = "https://registry.npmjs.org/"
; userconfig /Users/jay/.npmrc
username = "jayhendren"
; globalconfig /Users/jay/local/nodejs/etc/npmrc
global = true
globalconfig = "/Users/jay/local/nodejs/etc/npmrc"
globalignorefile = "/Users/jay/local/nodejs/etc/npmignore"
prefix = "/Users/jay/local/nodejs"
; default values
always-auth = false
bin-links = true
browser = null
ca = null
cache = "/Users/jay/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cert = null
color = true
depth = null
description = true
dev = false
editor = "/usr/bin/vim"
; email = "" (overridden)
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
group = 20
heading = "npm"
https-proxy = null
ignore-scripts = false
init-module = "/Users/jay/.npm-init.js"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
json = false
key = null
link = false
local-address = undefined
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "v0.10.25"
npat = false
onload-script = false
optional = true
parseable = false
production = false
proprietary-attribs = true
proxy = null
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = false
save-bundle = false
save-dev = false
save-optional = false
searchexclude = null
searchopts = ""
searchsort = "name"
shell = "/bin/zsh"
shrinkwrap = true
sign-git-tag = false
strict-ssl = true
tag = "latest"
tmp = "/var/folders/sq/ls98jmdd09l__xwpxq3qqmpw0000gn/T/"
umask = 18
unicode = true
unsafe-perm = true
usage = false
user = "nobody"
user-agent = "node/v0.10.25 darwin x64"
userconfig = "/Users/jay/.npmrc"
; username = "" (overridden)
version = false
versions = false
viewer = "man"
答案 0 :(得分:4)
要从缓存强制安装软件包,您可以使用以下方法:
$ npm --cache-min 9999999 install
答案 1 :(得分:0)
使用标记组合来模拟skip-installed
global = false
link = true
foo +-- node_modules +-- blerg (1.2.5) <---[A] +-- bar (1.2.3) <---[B] | `-- node_modules | +-- baz (2.0.2) <---[C] | | `-- node_modules | | `-- quux (3.2.0) | `-- asdf (2.3.4) `-- baz (1.2.3) <---[D] `-- node_modules `-- quux (3.2.0) <---[E]
<强>参考强>
答案 2 :(得分:-1)
我跑了&#34; npm prune&#34;在我的项目中,删除不必要的包(即不依赖项,并给你那令人恼火的&#34;无关的&#34;错误消息)。一个副作用似乎是删除你正在谈论的冗余包。例如,gulp需要gulp-util包。因为那已经在&#34;顶部&#34;等级,它已从gulp自己的节点模块中删除。