我一直在尝试在我的package.json文件上运行npm安装,但是遇到了很多麻烦。根据我的所有依赖性,它一直说“错误:尝试解锁XXX,但尚未锁定”。这是其中之一:
Error: Attempt to unlock tbd@~0.6.4, which hasn't been locked
at unlock (/usr/local/lib/node_modules/npm/lib/cache.js:1304:11)
at cb (/usr/local/lib/node_modules/npm/lib/cache.js:646:5)
at /usr/local/lib/node_modules/npm/lib/cache.js:655:20
at /usr/local/lib/node_modules/npm/lib/cache.js:1290:7
at /usr/local/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
at Object.oncomplete (fs.js:107:15)
如果我尝试以sudo形式运行它,它似乎会更进一步并开始安装一些软件包,但弹出一些新错误:
> chokidar@0.8.1 postinstall /Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/chokidar
> node setup-deps.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:811
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:811:23)
at startup (node.js:58:13)
at node.js:902:3
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q'
npm ERR! error rolling back karma@0.10.9 { [Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q' }
npm ERR! Error: ENOENT, chown '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/socket.io/lib/socket.io.js'
我最近更新了我的节点和npm安装。所以也许与它有关。另外,我的大部分开发工作都在办公室里,今天我正在使用VPN,因此也许与此有关。
有任何想法吗?
我遇到了同样的问题,并试图修复与npm相关的文件和目录的权限/所有权达数小时之久,但运气不佳。
突然,我发现
~/.npmrc
文件中包含cache
指向不存在的目录的条目。删除了该cache
属性以使用默认缓存位置,现在已解决。