求教npm install mongoose 一直在node-gyp.js" rebuild 卡住了怎么破?
发布于 9 年前 作者 khahux 18725 次浏览 最后一次编辑是 8 年前 来自 问答

如题

13 回复

前几天刚被卡过,换个淘宝的npm源试试,或者等网速好点就行了

npm默认是从国外的网站获取代码包吧,有时候国外网站会阻塞 ,翻*墙后下载就好了

@Ricardo-Li 这个问题可能是 node-gyp 的问题,跟网速没关系。我也一直不懂怎么处理这问题,印象中有人重装 node-gyp 然后成功了。

加上 npm install --verbose 看看呗

ps awufx, 看看具体卡在哪个命令

@Ricardo-Li @cuidezhu @alsotang @yorkie @jysperm 问题已经解决,学nodejs没几天,学校万恶校园网linux没客户端,在windows下折腾,昨天查好久应该是没装Windows SDK编译不过去,后来装了Microsoft .NET Framework SDK v2.0 (64bit),把vcbuild.exe加到环境变量后,题目那个错误没了,又报两个错误(error MSB6006: “VCBuild.exe”已退出,代码为 -1 和 Cannot open include file: ‘cstdlib’:), 安装 npm install node-gyp -g npm install bcrypt -g 均失败 搜搜有人说装vs2012。。。。。。那么大的东东,顿时蛋疼失去折腾windows的勇气,于是放弃windows折腾, 跪求室友给用电脑开wifi(室友最后勉强答应给10K小水管),我也是各种悲伤, 进Linux后一切顺利基本没遇到什么问题,以后有问题再来请教 github均已加关注,谢谢各位了

@khahux windows就是蛋疼啊

@alsotang 现在不疼了,谢谢诸位

我也碰到这个问题,虽然问题已解决,这里粘贴一下官方的提示(windows需要装一堆东西lol):

You will also need to install:
On Unix:
	* python (v2.7 recommended, v3.x.x is not supported)
	* make
	* A proper C/C++ compiler toolchain, like GCC
	
On Windows:
	* Python (v2.7.3 recommended, v3.x.x is not supported)
	
	Windows XP/Vista/7:
		* Microsoft Visual Studio C++ 2010 (Express version works well)
		* For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
		* If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first.
		* If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1
	
	Windows 7/8:
		* Microsoft Visual Studio C++ 2012 for Windows Desktop (Express version works well)

@khahux 试试 Vagrant 吧,挺好用的

@ruanyl 我以前在 Linux 上卡在 node-gyp, 也是因为没装 python 和 g++

遇到同样问题快要奔溃,终于解决 首先删除 $HOME/.node-gyp rm -rf ~/.node-gyp

然后重新安装最新的 node-gyp 包 npm i node-gyp -g

然后移除直接安装但build失败的 nodemodules rm -rf ./project/node_modules

最后重新 npm i -d 就行

最初解决方案出自: https://github.com/nodejs/node-gyp/issues/809

还有一种情况是文件路径里面有空格,将空格移除即可。

回到顶部