【问题标题】:node.js install node-protobuf on windows10node.js 在 windows10 上安装 node-protobuf
【发布时间】:2016-08-05 09:33:11
【问题描述】:

我这几天尝试在win10上安装node-protobuf。我已经遵循了一些quides / readmes,如何去做,但没有成功。现在我被困在这里:

 C:\rie>npm install node-protobuf
/
> node-protobuf@1.3.3 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! node-protobuf@1.3.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-protobuf@1.3.3 install script 'node-gyp rebuild'.

在centos上没有问题。

【问题讨论】:

    标签: node.js node-gyp


    【解决方案1】:

    我猜你没有仔细阅读文档,安装这个包你需要一些工具和配置。

    首先您必须获得 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 Release。

    接下来,运行 vsprojects/extract-includes.bat,它将复制所需的头文件到 vsprojects/include 中。

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

    现在只需 npm install node-protobuf 就可以了。

    仍然面临问题,然后确保上述所有内容都已安装并完成,然后检查您的互联网连接一次..

    【讨论】:

    • 我认为,ms-tools 还可以。我已经使用“npm install --global --production windows-build-tools”安装了 MS Visual c++ Build Tools。问题可能是“编译 libprotobuf。”。能找到,但是怎么编译呢?
    猜你喜欢
    • 2016-12-09
    • 1970-01-01
    • 2017-12-21
    • 1970-01-01
    • 2020-08-01
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多