2016-08-05 154 views
0

我试图在几天内在win10上安装node-protobuf。我已经跟随了一些quides/readmes,如何去做,但没有成功。现在我卡在这里:node.js在windows10上安装node-protobuf

C:\rie>npm install node-protobuf 
/
> [email protected] install C:\rie\node_modules\node-protobuf 
> node-gyp rebuild 


C:\rie\node_modules\node-protobuf>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\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 
    native.cpp 
    parse.cpp 
    serialize.cpp 
c:\rie\node_modules\node-protobuf\src\common.h(11): fatal error C1083: Cannot open include file: 'google/protobuf/descriptor.h': No suc 
h file or directory (compiling source file ..\src\native.cpp) [C:\rie\node_modules\node-protobuf\build\protobuf.vcxproj] 
c:\rie\node_modules\node-protobuf\src\common.h(11): fatal error C1083: Cannot open include file: 'google/protobuf/descriptor.h': No suc 
h file or directory (compiling source file ..\src\serialize.cpp) [C:\rie\node_modules\node-protobuf\build\protobuf.vcxproj] 
c:\rie\node_modules\node-protobuf\src\common.h(11): fatal error C1083: Cannot open include file: 'google/protobuf/descriptor.h': No suc 
h file or directory (compiling source file ..\src\parse.cpp) [C:\rie\node_modules\node-protobuf\build\protobuf.vcxproj] 
c:\rie\node_modules\node-protobuf\src\common.h(11): fatal error C1083: Cannot open include file: 'google/protobuf/descriptor.h': No suc 
h file or directory (compiling source file ..\src\init.cpp) [C:\rie\node_modules\node-protobuf\build\protobuf.vcxproj] 
gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1 
gyp ERR! stack  at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23) 
gyp ERR! stack  at emitTwo (events.js:87:13) 
gyp ERR! stack  at ChildProcess.emit (events.js:172:7) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) 
gyp ERR! System Windows_NT 10.0.10586 
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
gyp ERR! cwd C:\rie\node_modules\node-protobuf 
gyp ERR! node -v v4.4.5 
gyp ERR! node-gyp -v v3.3.1 
gyp ERR! not ok 
npm ERR! Windows_NT 10.0.10586 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-protobuf" 
npm ERR! node v4.4.5 
npm ERR! npm v2.15.5 
npm ERR! code ELIFECYCLE 

npm ERR! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. 

在centos上,没有问题。

回答

0

我想你没有很好的阅读文档,要安装这个软件包,你需要一些工具和配置来完成你的工作。

首先,您必须获得Microsoft Visual C++ 2010.Express很好,但如果安装SP1,则需要从这里重新安装x64编译器。 Windows的Node.js发行版已包含node-gyp工具,因此您不必担心它。只要您的编译器版本与您的Node.js安装兼容(即64代表64和32代表32),VC++ 2012/2013应该可以正常工作。对于在Windows上编译本地模块的任何问题,请参阅node-gyp存储库。

接下来,编译libprotobuf。从Google获取它,打开vsprojects/protobuf.sln并根据您的操作系统版本进行编译。对于Windows 64,您必须编译64位库,因为您的系统上的Node.js是64位。默认情况下只有32位目标,所以你必须手动添加64位。打开libprotobuf项目属性并将CRT设置为多线程(而不是DLL)。编译libprotobuf发布。

接下来,运行vsprojects/extract-includes.bat,它将复制vsprojects/include中所需的标题。

创建LIBPROTOBUF环境变量,指向要放置libprotobuf文件的某个文件夹。你可以在命令行提示符下使用SET LIBPROTOBUF = path,或者使用像RapidEE这样的工具。将libprotobuf.lib放入$(LIBPROTOBUF)/ lib,并将文件包含到$(LIBPROTOBUF)/ include。你完成了。

现在只需要npm install node-protobuf,它应该没问题。

仍然面临的问题,然后确保上述所有已安装并完成,则一旦检查您的网络连接..

+0

我想,MS-工具都OK。我用“npm install --global --production windows-build-tools”安装了MS Visual C++ Build Tools。问题可能是“编译libprotobuf”。我可以找到它,但如何编译它? – ajlind