lwip在azure web应用程序中的node-gyp重build问题:致命错误C1083:无法打开包含文件:'nan.h':没有这样的文件或目录

我已经在Azure中部署了一个节点应用程序。 在azure色的web应用程序中的环境细节如下 –

Python version : 2.7 Platform : 32 bit Dotnet framework : 4.6 Node version : 6.3.0 Npm version: 3.10.3 

在我的应用程序中,我正在使用lwip,它需要使用Visual C ++构build工具进行构build。 当我做npm installnode-gyp rebuildnpm install它的失败。 我收到许多相同的消息types的错误信息

“致命错误C1083:无法打开包含文件:'nan.h':没有这样的文件或目录”

我已经检查了nan模块是否存在于node_modules中。

完整的日志附在这里:

 D:\home\site\wwwroot>npm install > lwip@0.0.9 install D:\home\site\wwwroot\node_modules\lwip > node-gyp rebuild D:\home\site\wwwroot\node_modules\lwip>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\npm\3.10.3\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild ) Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. init.cpp d:\home\site\wwwroot\node_modules\lwip\src\decoder\decoder.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_decoder.vcxproj] util.cpp d:\home\site\wwwroot\node_modules\lwip\src\decoder\decoder.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_decoder.vcxproj] buffer_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\decoder\decoder.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_decoder.vcxproj] jpeg_decoder.cpp d:\home\site\wwwroot\node_modules\lwip\src\decoder\decoder.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_decoder.vcxproj] png_decoder.cpp d:\home\site\wwwroot\node_modules\lwip\src\decoder\decoder.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_decoder.vcxproj] gif_decoder.cpp d:\home\site\wwwroot\node_modules\lwip\src\decoder\decoder.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_decoder.vcxproj] init.cpp d:\home\site\wwwroot\node_modules\lwip\src\encoder\encoder.h(11): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_encoder.vcxproj] jpeg_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\encoder\encoder.h(11): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_encoder.vcxproj] png_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\encoder\encoder.h(11): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_encoder.vcxproj] gif_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\encoder\encoder.h(11): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_encoder.vcxproj] init.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] image.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] resize_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] rotate_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] blur_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] crop_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] mirror_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] pad_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] sharpen_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] hsla_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] opacify_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] paste_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] setpixel_worker.cpp d:\home\site\wwwroot\node_modules\lwip\src\image\image.h(13): fatal error C1083: Cannot open include file: 'nan.h': No such file or directory [D:\home\site\wwwroot\node_modules\lwip\build\lwip_image.vcxproj] gyp ERR! build error gyp ERR! stack Error: `msbuild` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Program Files (x86)\npm\3.10.3\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23) gyp ERR! stack at emitTwo (events.js:106:13) gyp ERR! stack at ChildProcess.emit (events.js:191:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12) gyp ERR! System Windows_NT 6.2.9200 gyp ERR! command "D:\\Program Files (x86)\\nodejs\\6.3.0\\node.exe" "C:\\Program Files (x86)\\npm\\3.10.3\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd D:\home\site\wwwroot\node_modules\lwip gyp ERR! node -v v6.3.0 gyp ERR! node-gyp -v v3.3.1 gyp ERR! not ok npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@0.3.8 npm WARN brief@0.0.1 No repository field. npm WARN brief@0.0.1 No license field. npm ERR! Windows_NT 6.2.9200 npm ERR! argv "D:\\Program Files (x86)\\nodejs\\6.3.0\\node.exe" "D:\\Program Files (x86)\\npm\\3.10.3\\node_modules\\npm\\bin\\npm-cli.js" "install" npm ERR! node v6.3.0 npm ERR! npm v3.10.3 npm ERR! code ELIFECYCLE npm ERR! lwip@0.0.9 install: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the lwip@0.0.9 install script 'node-gyp rebuild'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the lwip package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs lwip npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls lwip npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! D:\home\site\wwwroot\npm-debug.log 

谢谢

目前,Azure Azure应用服务不支持所有本地模块,并且可能会在编译具有特定先决条件的那些模块时失败。

作为解决方法,您可以在npm install了所有本机模块的必备软件的本地Windows机器上运行npm install 。 然后,将创build的node_modules文件夹作为应用程序的一部分部署到Azure App Service。

有关更多信息,请参阅https://azure.microsoft.com/zh-CN/documentation/articles/nodejs-use-node-modules-azure-apps/