41

我已经安装了全局 npm 包jslint,它就在这里

$ ls -la /usr/local/bin/jslint
lrwxr-xr-x  1 lust  admin  40 Feb 12 15:31 /usr/local/bin/jslint -> ../lib/node_modules/jslint/bin/jslint.js

$ ls -la /usr/local/lib/node_modules/jslint/bin 
total 8
drwxr-xr-x   3 lust  staff   102 Apr 16  2012 .
drwxr-xr-x  10 lust  staff   340 Feb 12 15:31 ..
-rwxr-xr-x   1 lust  staff  2330 Apr 16  2012 jslint.js

$ which jslint
/usr/local/bin/jslint

$ head -3 /usr/local/bin/jslint 
#!/usr/bin/env node

var linter = require("../lib/linter");

因此,毫无疑问,此时jslint实际上是从这个目录而不是在这里运行的:

$ ls -la .npm/jslint/0.1.9/package/bin/         
total 8
drwxr-xr-x  3 lust  staff   102 Apr 16  2012 .
drwxr-xr-x  9 lust  staff   306 Feb 12 15:31 ..
-rwxr-xr-x  1 lust  staff  2330 Apr 16  2012 jslint.js

包裹似乎有两份副本,一份在/usr/local/,一份在~/.npm. 为什么里面有一个,.npm我可以安全地删除它吗?

4

1 回答 1

87

~/.npm是 npm 用来避免多次重新下载同一个包的缓存。删除它没有坏处。您可以使用以下命令清空它:

npm cache clean
于 2013-02-12T21:51:17.850 回答