title: Bower installation errors on Windows, ENOENT, ENOTEMPTY
body: <p>I am on Windows 8, running command prompt as administrator. I run this command:</p>
  
  <pre><code>npm install -g bower
  </code></pre>
  
  <p>This gives me errors. I can't provide the full output to npm-debug.log since I am limited to 30000 characters. StackOverflow complains about the length of my post and that it appears to contain code that is not properly formatted as code even though I put it in a <code>pre</code>, so I removed all lines with " silly " or " verbose ", and I also cut away everything except the end, which is where the interesting bits appear to be.</p>
  
  <p>npm-debug.log contains the following:</p>
  
  <pre><code>3850 info install bower-endpoint-parser@0.2.2
  3851 info postinstall bower-logger@0.2.2
  3864 info install lru-cache@2.5.0
  3865 http 304 https://registry.npmjs.org/lodash.debounce
  3868 info postinstall bower-endpoint-parser@0.2.2
  3870 info postinstall lru-cache@2.5.0
  3872 info preinstall bower-config@0.5.2
  3877 info preinstall nopt@3.0.1
  3878 error error rolling back Error: ENOTEMPTY, rmdir 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q'
  3878 error error rolling back  bower@1.3.7 { [Error: ENOTEMPTY, rmdir 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q']
  3878 error error rolling back   errno: 53,
  3878 error error rolling back   code: 'ENOTEMPTY',
  3878 error error rolling back   path: 'C:\\Users\\Mikal\\AppData\\Roaming\\npm\\node_modules\\bower\\node_modules\\q' }
  3879 error Error: No compatible version found: chalk@'^0.4.0'
  3879 error Valid install targets:
  3879 error ["0.1.0","0.1.1","0.2.0","0.2.1","0.3.0","0.4.0","0.5.0"]
  3879 error     at installTargetsError (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:719:10)
  3879 error     at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:641:10
  3879 error     at RegClient.get_ (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:101:14)
  3879 error     at RegClient.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:37:12)
  3879 error     at fs.js:266:14
  3879 error     at Object.oncomplete (fs.js:107:15)
  3880 error If you need help, you may report this log at:
  3880 error     &lt;http://github.com/isaacs/npm/issues&gt;
  3880 error or email it to:
  3880 error     &lt;npm-@googlegroups.com&gt;
  3881 error System Windows_NT 6.2.9200
  3882 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  3883 error cwd C:\nodeapps
  3884 error node -v v0.10.11
  3885 error npm -v 1.2.30
  </code></pre>
  
  <p>From what I can understand there's an error because the <code>C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q</code> directory is not empty and thus cannot be removed. However, when I navigate there in Windows Explorer, there is no <code>q</code> directory inside of <code>\nodemodules\</code>.</p>
  
  <p>If I go to my command prompt and scroll as far up as I'm able to go, I find the following:</p>
  
  <pre><code>ream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm http GET https://registry.npmjs.org/optimist
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\chalk\node_modules\strip-ansi\readme.md'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\chalk\node_modules\strip-ansi\readme.md
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\chalk\node_modules\strip-ansi\readme.md
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\decompress-zip\lib\structures.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\decompress-zip\lib\structures.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\decompress-zip\lib\structures.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\inquirer\lib\prompts\input.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\inquirer\lib\prompts\input.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\inquirer\lib\prompts\input.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\fstream\lib\file-reader.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\fstream\lib\file-reader.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\fstream\lib\file-reader.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm http GET https://registry.npmjs.org/osenv/0.0.3
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\semver\semver.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\semver\semver.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\semver\semver.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm http 304 https://registry.npmjs.org/osenv/0.0.3
  npm http 200 https://registry.npmjs.org/optimist
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\request\request.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\request\request.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\request\request.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  npm ERR! Error: ENOENT, lstat 'C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\handlebars\dist\handlebars.amd.js'
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bower"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR! path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\handlebars\dist\handlebars.amd.js
  npm ERR! fstream_path C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\handlebars\dist\handlebars.amd.js
  npm ERR! fstream_type File
  npm ERR! fstream_class FileWriter
  npm ERR! code ENOENT
  npm ERR! errno 34
  npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
  npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Starting to take matters into my own hands, I noticed that the folders mentioned in the <code>ENOENT, lstat</code> lines were missing. So I attempted to install them. Chalk would not install:</p>
  
  <pre><code>C:\nodeapps&gt;npm install -g chalk
  npm http GET https://registry.npmjs.org/chalk
  npm http 200 https://registry.npmjs.org/chalk
  npm http GET https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz
  npm http 200 https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz
  npm http GET https://registry.npmjs.org/escape-string-regexp
  npm http GET https://registry.npmjs.org/has-ansi
  npm http GET https://registry.npmjs.org/supports-color
  npm http GET https://registry.npmjs.org/ansi-styles
  npm http GET https://registry.npmjs.org/strip-ansi
  npm http 200 https://registry.npmjs.org/ansi-styles
  npm http 200 https://registry.npmjs.org/strip-ansi
  npm ERR! Error: No compatible version found: strip-ansi@'^0.3.0'
  npm ERR! Valid install targets:
  npm ERR! ["0.1.0","0.1.1","0.2.0","0.2.1","0.2.2","0.3.0"]
  npm ERR!     at installTargetsError (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:719:10)
  npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:641:10
  npm ERR!     at saved (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:138:7)
  npm ERR!     at Object.oncomplete (fs.js:107:15)
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "chalk"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm http 200 https://registry.npmjs.org/escape-string-regexp
  npm http 200 https://registry.npmjs.org/has-ansi
  npm http 200 https://registry.npmjs.org/supports-color
  npm ERR!
  npm ERR! Additional logging details can be found in:
  npm ERR!     C:\nodeapps\npm-debug.log
  npm ERR! not ok code 0
  </code></pre>
  
  <p><code>Decompress-zip</code>, <code>Inquirer</code>, <code>fstream</code>, <code>semver</code>, <code>request</code> and <code>handlebars</code> would install, with some warnings.
  Retrying <code>chalk</code> after installing these did not work. From the "valid install targets" error line and some comments on a similar issue on Github with Macports, I got the idea that I should roll back npm to version 0.3.0.</p>
  
  <p>Couldn't figure out how to do it. <a href="https://github.com/npm/npm/issues/5470" rel="noreferrer">https://github.com/npm/npm/issues/5470</a> recommended <code>npm cache clean</code>, so I did that, followed by trying to install chalk again, which this time gave me</p>
  
  <pre><code>npm ERR! Error: No compatible version found: ansi-styles@'^1.1.0'
  npm ERR! Valid install targets:
  npm ERR! ["0.1.0","0.1.1","0.1.2","0.2.0","1.0.0","1.1.0"]
  npm ERR!     at installTargetsError (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:719:10)
  npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:641:10
  npm ERR!     at saved (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:138:7)
  npm ERR!     at Object.oncomplete (fs.js:107:15)
  npm ERR! If you need help, you may report this log at:
  npm ERR!     &lt;http://github.com/isaacs/npm/issues&gt;
  npm ERR! or email it to:
  npm ERR!     &lt;npm-@googlegroups.com&gt;
  
  npm ERR! System Windows_NT 6.2.9200
  npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "chalk"
  npm ERR! cwd C:\nodeapps
  npm ERR! node -v v0.10.11
  npm ERR! npm -v 1.2.30
  npm ERR!
  npm ERR! Additional logging details can be found in:
  npm ERR!     C:\nodeapps\npm-debug.log
  npm ERR! not ok code 0
  </code></pre>
  
  <p>This indicates to me that I should roll back to version "1.1.0" - unfortunately I don't know how to do this.</p>
  
  <p>On the previously linked GitHub issue, the person only managed to get it working by reinstalling node.js. So unless someone comes up with another solution soon, I think that's what I'll do.</p>