2016-08-05 158 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