Bug report: cache directory cant move
Opened this issue · 0 comments
AliMD commented
When you move cache directory to new location and update config you have error with old cache files
For example:
old location: /Users/alimd/.npm/lazy_cache/
new location: /DevTools/npm/lazy_cache
npm error:
app info npm_lazy at 0.0.0.0 port 4114
app info npm_lazy cache directory: /DevTools/npm/lazy_cache
app debug [GET] http://registry.npmjs.org/babel-generator
app debug cache get http://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.7.4.tgz
app debug [GET] http://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.7.4.tgz
app debug [304] http://registry.npmjs.org/path-exists
fs.js:584
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/Users/alimd/.npm/lazy_cache/9kyedi2g3krzfr'
at Error (native)
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:431:33)
at /DevTools/npm/lib/node_modules/npm_lazy/lib/package.js:100:63
at /DevTools/npm/lib/node_modules/npm_lazy/lib/resource.js:159:5
at Lifecycle.<anonymous> (/DevTools/npm/lib/node_modules/npm_lazy/lib/lifecycle.js:32:7)
at Lifecycle.c (/DevTools/npm/lib/node_modules/npm_lazy/node_modules/microee/index.js:34:13)
at Lifecycle.M.emit (/DevTools/npm/lib/node_modules/npm_lazy/node_modules/microee/index.js:23:12)
at Lifecycle.release (/DevTools/npm/lib/node_modules/npm_lazy/lib/lifecycle.js:19:10)
at Resource._afterFetch (/DevTools/npm/lib/node_modules/npm_lazy/lib/resource.js:251:11)
as you can see cache dir setting changed but npmlazy try to open old folder!, it work for new cached module and this bug just happened for old cached modules
My config
var path = require('path'),
homePath = path.normalize(process.env['NPM_HOME']);
module.exports = {
// Logging config
loggingOpts: {
// Print to stdout with colors
logToConsole: true,
// Write to file
logToFile: false,
// This should be a file path.
filename: homePath + '/npm_lazy.log'
},
// Cache config
// `cacheDirectory`: Directory to store cached packages.
//
// Note: Since any relative path is resolved relative to the current working
// directory when the server is started, you should use a full path.
cacheDirectory: homePath + '/lazy_cache',
// `cacheAge`: maximum age before an index is refreshed from remoteUrl
// - negative value means no refresh (e.g. once cached, never update the package.json metadata)
// - zero means always refresh (e.g. always ask the registry for metadata)
// - positive value means refresh every n milliseconds
// (e.g. 60 * 60 * 1000 = expire metadata every 60 minutes)
//
// Note: if you want to use `npm star` and other methods which update
// npm metadata, you will need to set cacheAge to 0. npm generally wants the latest
// package metadata version so caching package metadata will interfere with it.
// Recommended setting: 0
cacheAge: 7 * 24 * 60 * 60 * 1000,
// Request config
// max milliseconds to wait for each HTTP response
httpTimeout: 20000,
// maximum number of retries per HTTP resource to get
maxRetries: 5,
// whether or not HTTPS requests are checked against Node's list of CAs
// set false if you are using your own npm mirror with a self-signed SSL cert
rejectUnauthorized: false,
// Remote and local URL
// external url to npm_lazy, no trailing /
externalUrl: 'http://localhost:4114',
// registry url with trailing /
remoteUrl: 'http://registry.npmjs.org/',
// bind port and host
port: 4114,
host: '0.0.0.0',
// Proxy config
// You can also configure this using the http_proxy and https_proxy environment variables
// cf. https://wiki.archlinux.org/index.php/proxy_settings
proxy: {
// http: 'http://1.2.3.4:80/',
// https: 'http://4.3.2.1:80/'
}
};
If you clear the cache maybe this problem solved but if you want to keep old cache files you must to make a symbolic link new dir to old !