Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`npm install` installs all dependencies of my project over the network, even if they are already installed or available from cache

Tags:

node.js

npm

whenever I run npm install in my project directory, npm fetches and installs all dependencies even if they're already installed in node_modules. Npm does not install from my cache in ~/.npm/, even though there are already an extremely large number of packages in my cache.

Here is my npm config settings from 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"

Does anybody know why npm insists on fetching new packages over and over and over again?

like image 733
jayhendren Avatar asked Feb 03 '14 22:02

jayhendren


1 Answers

To install the packages from the cache force, you can use the following way:

$ npm --cache-min 9999999 install

See also: https://addyosmani.com/blog/using-npm-offline/

like image 62
Daijirō Wachi Avatar answered Oct 26 '22 17:10

Daijirō Wachi