【发布时间】:2016-02-27 01:30:14
【问题描述】:
在我们的项目上运行 "npm install" 时遇到问题。找不到某个文件:
fatal error C1083: Cannot open include file: 'windows.h'
它似乎来自 node-gyp 模块:
c:\程序 文件\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_lo ad_hook.c(13):
致命错误 C1083:无法打开包含文件:“windows.h”:没有这样的 文件或目录 [D:\ngs-frontend-next\node_modules\browser-sync\node_module s\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\buil d\binding.sln]
这个节点-gyp 对我们来说似乎是一个永无止境的痛苦之源。起初它抱怨它需要python,所以我们安装了它。然后它抱怨它需要我们安装的VCBuild(使用.NET 2.0 SDK),现在我们有这个错误。就好像错误变得越来越模糊,感觉就像我们走错了路。
奇怪的是,我们团队中的其他人运行 npm-install 的问题为零。
完整的错误如下所示:
c:\程序 文件\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_lo ad_hook.c(13):
致命错误 C1083:无法打开包含文件:“windows.h”:没有这样的 文件或目录 [D:\ngs-frontend-next\node_modules\browser-sync\node_module s\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\buil d\binding.sln]
gyp 错误!构建错误 gyp ERR!堆栈错误:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe失败 退出代码:ChildProcess.onExit 的 1 个堆栈(C:\Program 文件\nodejs\node_modules\npm\node _modules\node-gyp\lib\build.js:270:23) gyp 错误!堆栈在 emitTwo (events.js:87:13) gyp ERR! ChildProcess.emit 的堆栈 (events.js:172:7)gyp 错误!堆栈在 Process.ChildProcess._handle.onexit(内部/child_proces s.js:200:12)gyp 错误!系统 Windows_NT 6.1.7601 gyp 错误!命令 "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodej s\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" “重建” gyp ERR! cwd D:\ngs-frontend-next\node_modules\browser-sync\node_modules\socket。 io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil gyp 呃!节点 -v v4.2.2 gyp 错误!节点-gyp -v v3.0.3 gyp 错误!不好 npm WARN 可选 dep 失败,继续 utf-8-validate@1.2.1gifsicle@3.0.3 安装后 D:\ngs-frontend-next\node_modules\gulp-imagemin\nod e_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle 节点库/install.js
pacakge.json 看起来像这样:
{
"name": "Fast-nunjucks",
"version": "0.0.1",
"description": "A simple boilerplate using nunjucks as a template engine",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/willianjusten/Fast-nunjucks.git"
},
"keywords": [
"nunjucks",
"node",
"gulp",
"stylus"
],
"author": "Willian Justen de Vasconcellos",
"license": "ISC",
"bugs": {
"url": "https://github.com/willianjusten/Fast-nunjucks/issues"
},
"homepage": "https://github.com/willianjusten/Fast-nunjucks",
"devDependencies": {
"autoprefixer-stylus": "^0.7.1",
"browser-sync": "^2.8.2",
"gulp": "^3.9.0",
"gulp-cache": "^0.3.0",
"gulp-concat": "^2.6.0",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.3.0",
"gulp-minify-html": "^1.0.4",
"gulp-nunjucks-html": "^1.2.2",
"gulp-order": "^1.1.1",
"gulp-plumber": "^1.0.1",
"gulp-stylus": "^2.0.6",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.6",
"jeet": "^6.1.2",
"kouto-swiss": "^0.11.13",
"minimist": "^1.1.3",
"rupture": "^0.6.1"
},
"dependencies": {
"gulp-install": "^0.6.0"
}
}
【问题讨论】:
-
“奇怪的是,我们团队中的其他人运行 npm-install 的问题为零。” - 确保每个人都使用相同版本的节点。
-
这个问题你解决了吗?我有这样的东西。你能检查一下这个问题吗:stackoverflow.com/questions/34335043/… 可能你对我有一些有用的建议。
-
我在安装了 Visual Studio 2010 / 2013 / 2015 的 PC 上尝试了几天来解决这个构建问题,但没有成功。然后最终成功地在纯 Windows VM 中构建它。我不喜欢它,但它有效。
-
天哪。我不经常更新我的应用程序,但每次更新时,node-sass 在 npm 安装时都会失败。它真的变老了。没有其他选择吗?
-
顺便说一句,当构建以这种方式失败时(带有节点 gyp 驱动的本机编译问题),有没有办法保留部分编译的结果/工件以进一步调查?在我的情况下,我得到了错误,但是编译的源/二进制文件被 npm 进程的其余部分清理(所以我无法更详细地解决故障)
标签: javascript node.js npm node-gyp