title: npm install randomly fails on Windows
body: <p>When running <code>npm install</code> on our Windows build server, the command intermittently fails with </p>
  
  <pre><code>error   errno: -4048,
  error   code: 'EPERM',
  error   path: 'C:\\Users\\bamboo\\AppData\\Roaming\\npm-cache\\readable-stream\\1.0.33\\package\\package.json',
  error   parent: 'through2' }
  error Please try running this command again as root/Administrator.
  </code></pre>
  
  <p>even though the command is being executed as an administrator in a command prompt running as Administrator.  The package the command fails on varies each time and other Windows computers do not have this issue when running <code>npm install</code> with the same source.</p>
  
  <p>I've tried <code>npm cache clean</code> and manually deleting the contents of the C:\Users\%username%\AppData\npm-cache directory with no luck.  I've also examined the permissions on the npm-cache directory, the NodeJS install directory, and the directory containing the source code checkout and all show that the administrator group has full permissions and that the admin user (who is running the <code>npm install</code> command) owns the directory.  I've also tried the latest version of npm (2.13.4), as well as an older version (2.11.3).</p>
  
  <p>What is causing this permissions error?</p>
  
  <p>Below is the content of the npm-debug.log file:</p>
  
  <pre><code>236980 info install write-file-atomic@1.1.2
  236981 info postinstall write-file-atomic@1.1.2
  236982 info install npm@2.13.4
  236983 info postinstall npm@2.13.4
  236984 verbose unlock done using C:\Users\bamboo\AppData\Roaming\npm-cache\_locks\npm-723363012edbbbaa.lock for c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\npm
  236985 verbose stack Error: EPERM, rename 'C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json'
  236985 verbose stack     at Error (native)
  236986 verbose cwd c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
  236987 error Windows_NT 6.3.9600
  236988 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--msvs_version=2013"
  236989 error node v0.12.7
  236990 error npm  v2.11.3
  236991 error path C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json
  236992 error code EPERM
  236993 error errno -4048
  236994 error Error: EPERM, rename 'C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json'
  236994 error     at Error (native)
  236994 error  { [Error: EPERM, rename 'C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json']
  236994 error   errno: -4048,
  236994 error   code: 'EPERM',
  236994 error   path: 'C:\\Users\\bamboo\\AppData\\Roaming\\npm-cache\\readable-stream\\1.0.33\\package\\package.json',
  236994 error   parent: 'through2' }
  236995 error Please try running this command again as root/Administrator.
  236996 verbose exit [ -4048, true ]
  236997 verbose unbuild node_modules\gulp-replace-task\node_modules\through2
  236998 info preuninstall through2@0.6.5
  236999 info uninstall through2@0.6.5
  237000 verbose unbuild rmStuff through2@0.6.5 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
  237001 verbose unbuild rmStuff in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules
  237002 info postuninstall through2@0.6.5
  237003 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules\through2 is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
  237004 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules\through2
  237005 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules\through2
  237006 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules
  237007 verbose unbuild node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
  237008 info preuninstall utf-8-validate@1.1.0
  237009 info uninstall utf-8-validate@1.1.0
  237010 verbose unbuild rmStuff utf-8-validate@1.1.0 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
  237011 verbose unbuild rmStuff in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
  237012 info postuninstall utf-8-validate@1.1.0
  237013 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
  237014 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
  237015 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
  237016 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
  237017 verbose unbuild node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
  237018 info preuninstall bufferutil@1.1.0
  237019 info uninstall bufferutil@1.1.0
  237020 verbose unbuild rmStuff bufferutil@1.1.0 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
  237021 verbose unbuild rmStuff in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
  237022 info postuninstall bufferutil@1.1.0
  237023 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
  237024 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
  237025 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
  237026 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
  237027 verbose unbuild node_modules\gulp-replace-task
  237028 info preuninstall gulp-replace-task@0.1.0
  237029 info uninstall gulp-replace-task@0.1.0
  237030 verbose unbuild rmStuff gulp-replace-task@0.1.0 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
  237031 info postuninstall gulp-replace-task@0.1.0
  237032 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
  237033 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task
  237034 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task
  237035 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
  </code></pre>