我在Windows 8上,以管理员身份运行命令提示符。我运行这个命令:
npm install -g bower
这给了我错误。我无法向npm-debug.log提供完整输出,因为我限制为30000个字符。 StackOverflow抱怨我的帖子的长度,并且它似乎包含未正确格式化为代码的代码,即使我把它放在pre
中,所以我删除了所有的行"傻"或"啰嗦",除了结尾之外,我还删除了所有内容,这是有趣的部分所在。
npm-debug.log包含以下内容:
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.<anonymous> (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 <http://github.com/isaacs/npm/issues>
3880 error or email it to:
3880 error <npm-@googlegroups.com>
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
据我所知,由于C:\Users\Mikal\AppData\Roaming\npm\node_modules\bower\node_modules\q
目录不为空而无法删除,因此出现错误。但是,当我在Windows资源管理器中导航时,q
内没有\nodemodules\
目录。
如果我转到我的命令提示符并向上滚动,我能够找到以下内容:
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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)
编辑:
开始自行解决问题,我注意到ENOENT, lstat
行中提到的文件夹丢失了。所以我试图安装它们。粉笔无法安装:
C:\nodeapps>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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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
Decompress-zip
,Inquirer
,fstream
,semver
,request
和handlebars
会安装一些警告。
安装后重试chalk
不起作用。来自&#34;有效的安装目标&#34;关于Github和Macports上类似问题的错误行和一些评论,我明白我应该将npm回滚到版本0.3.0。
无法弄清楚如何做到这一点。 https://github.com/npm/npm/issues/5470建议npm cache clean
,所以我这样做了,然后又尝试再次安装粉笔,这次给了我
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! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
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
这向我表明我应该回到版本&#34; 1.1.0&#34; - 不幸的是,我不知道该怎么做。
在之前链接的GitHub问题上,此人只是通过重新安装node.js来设法让它工作。因此,除非有人很快提出另一种解决方案,否则我认为这就是我要做的事情。
答案 0 :(得分:11)
我刚刚尝试在Windows 7计算机上安装bower时遇到了同样的问题。我可以保证重新安装node.js解决了问题!
答案 1 :(得分:3)
我在Windows 7上遇到了类似的问题并且已经修复了运行:
npm rm -g bower
npm cache clean
npm i -g bower
答案 2 :(得分:3)
Windows本身处理任意大小的目录,但Windows资源管理器和高级Windows API具有有限的目录深度。
不幸的是,深层模块嵌套是节点模块加载语义和npm解决其他包管理器发生的依赖性地狱的结合。 (您希望使用两个具有互不兼容的依赖关系的模块。)
npm错误在这里:Provide a way to flatten dependencies to one level to prevent max path issues on windows
您可以使用以下内容完全删除模块:npm uninstall <modulename>
或者,如果你想删除目录,请获取rimraf:
npm install -g rimraf
rimraf <dirname>
重复数据删除也可能使您的树处于更易于管理的状态:npm dedup
答案 3 :(得分:3)
尝试通过NPM安装Bower时遇到了类似的问题。在阅读了所有关于npm的全局缓存的建议之后:
npm -g cache clean
它没有解决我的问题。我意识到NPM版本(1.2.18)和一些较新的软件包(dezalgo,q,asap,......)存在严重的兼容性问题。
这是最好的部分,我认为我实际上是使用以下内容更新NPM:
npm install -g npm
...但我的控制台没有显示错误或警告,所以我假设所有内容都更新到最新版本。相反,在意识到我对NPM的更新没有激活之后我做了一些挖掘以找到更新你的npm的最佳方法:
curl https://www.npmjs.org/install.sh | sh
获胜者,冠军,鸡肉晚餐! NPM已更新至2.1.7版。在NPM更新后,我没有遇到任何问题:
npm install bower
我认为这将适用于那些有依赖关系的ENOENT问题的人。干杯!
答案 4 :(得分:1)
仅在Windows操作系统上出现此问题。并且仅在路径已存在(先前安装)且您更新时才会出现。
节点npm包管理器不会在一个共享供应商文件夹中安装依赖项(例如,像Composer一样),但始终位于供应商文件夹node_modules
子目录中。这导致疯狂的路径深度,如下所示(整数替换原始文件夹名称):
./project/node_modules/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/
这不是我到目前为止看到的最大深度。
Windows的最大路径长度为260个字符。 Windows创建具有疯狂深度的路径是没有问题的。问题是从该路径中删除。要删除此类路径,您必须手动进入并逐位重命名文件夹,直到达到总路径长度<260 chars。在更新(并因此添加)新文件夹之前尝试删除文件夹时,npm与Windows并行失败。
根据@Rarst的评论,有一个解决方案:使用robocopy
。按照以下步骤尽可能准确,非常非常重要。如果你不这样做,你可以擦除你的硬盘!。没有任何保证隐含,以下只是我所做的事情的文档,没有推荐,也没有任何教程或其他任何建议。
_empty
文件夹node_modules
)
cmd
一起作为管理员使用)robocopy _empty dir-to-delete /MIR /s
请记住:重复上述步骤时,您可以清除硬盘。因此,如果你这样做,你自己承担风险,你应该继续极端谨慎。
答案 5 :(得分:0)
我有同样的错误,npm cache clear / clean没有解决我的问题。
从官方网站重新安装,而不是aptget解决我的问题。
从https://nodejs.org/下载tar.gz文件
提取:
tar -zxvf yourtarfile.tar.gz
cd intoyournodefolder
.configure
make
sudo make install
然后更新npm
sudo npm install npm -g