Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is ~/.npm dir for?

I have installed the global npm package jslint and it lives here

$ 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"); 

So it is without any doubt whatsoever at this point that jslint is in fact being run from this dir and not here:

$ 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 

There appear to be two copies of the package, one in /usr/local/ and one in ~/.npm. Why is there one in .npm and is it safe for me to remove it?

like image 797
Steven Lu Avatar asked Feb 12 '13 21:02

Steven Lu


People also ask

How do I find npm directory?

The command npm root will tell you the effective installation directory of your npm packages. If your current working directory is a node package or a sub-directory of a node package, npm root will tell you the local installation directory.

Where do I put npm packages?

NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.

What is npm and why use it?

npm is the world's largest Software Registry. The registry contains over 800,000 code packages. Open-source developers use npm to share software. Many organizations also use npm to manage private development.

Where is npm folder in Windows?

On most systems, this is /usr/local . On Windows, it's %AppData%\npm . On Unix systems, it's one level up, since node is typically installed at {prefix}/bin/node rather than {prefix}/node.exe .


1 Answers

~/.npm is a cache that npm uses to avoid re-downloading the same package multiple times. There's no harm in removing it. You can empty it with the command:

npm cache clean 
like image 73
Trevor Burnham Avatar answered Sep 18 '22 05:09

Trevor Burnham