node.js - Npm 模块安装 Visual Studio 错误

标签 node.js

我在 Windows 8.1 x64 上,我有 Visual Studio 2013 Ultimate。我以管理员身份运行控制台并执行 npm install -g karma (与其他模块相同),但出现此错误:

npm WARN 可选 dep 失败,继续 fsevents@0.2.0 /

ws@0.4.31 install C:\Program Files (x86)\nodejs\node_modules\karma\node_module s\socket.io\node_modules\socket.io-client\node_modules\ws (node-gyp rebuild 2> builderror.log) || (exit 0)

C:\Program Files (x86)\nodejs\node_modules\karma\node_modules\socket.io\node_mod
ules\socket.io-client\node_modules\ws>node "C:\Users\Filip\AppData\Roaming\npm\n
ode_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" r
ebuild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.t
argets(64,5): error MSB8020: The build tools for Visual Studio 2010 (Platform T
oolset = 'v100') cannot be found. To build using the v100 build tools, please i
nstall Visual Studio 2010 build tools.  Alternatively, you may upgrade to the c
urrent Visual Studio tools by selecting the Project menu or right-click the sol
ution, and then selecting "Upgrade Solution...". [C:\Program Files (x86)\nodejs
\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_m
odules\ws\build\bufferutil.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.t
argets(64,5): error MSB8020: The build tools for Visual Studio 2010 (Platform T
oolset = 'v100') cannot be found. To build using the v100 build tools, please i
nstall Visual Studio 2010 build tools.  Alternatively, you may upgrade to the c
urrent Visual Studio tools by selecting the Project menu or right-click the sol
ution, and then selecting "Upgrade Solution...". [C:\Program Files (x86)\nodejs
\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_m
odules\ws\build\validation.vcxproj]
karma@0.12.16 C:\Program Files (x86)\nodejs\node_modules\karma
├── di@0.0.1
├── graceful-fs@2.0.3
├── rimraf@2.2.8
├── colors@0.6.2
├── mime@1.2.11
├── q@0.9.7
├── chokidar@0.8.2 (recursive-readdir@0.0.2)
├── minimatch@0.2.14 (sigmund@1.0.0, lru-cache@2.5.0)
├── optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.10)
├── source-map@0.1.34 (amdefine@0.1.0)
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── lodash@2.4.1
├── log4js@0.6.15 (semver@1.1.4, async@0.1.15, readable-stream@1.0.27-1)
├── http-proxy@0.10.4 (pkginfo@0.3.0, utile@0.2.1)
├── useragent@2.0.8 (lru-cache@2.2.4)
├── connect@2.12.0 (uid2@0.0.3, methods@0.1.0, cookie-signature@1.0.1, fresh@0.2
.0, pause@0.0.1, debug@0.8.1, qs@0.6.6, bytes@0.2.1, buffer-crc32@0.2.1, batch@0
.5.0, raw-body@1.1.2, cookie@0.1.0, negotiator@0.3.0, send@0.1.4, multiparty@2.2
.0)
└── socket.io@0.9.17 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.io-c
lient@0.9.16)

最佳答案

确保您拥有运行 node-gyp 所需的所有软件,该软件可以编译 ws 使用的 C++ 代码(Web Sockets),该代码由 socket.io 使用.

您可以通过环境变量配置 gyp 使用的 Visual Studio 版本,这样您就可以避免设置 --msvs_version=2012 属性。

例子:

  • 为 Visual Studio 2012 设置 GYP_MSVS_VERSION=2012
  • 设置GYP_MSVS_VERSION=2013e('e'代表'express edition')

完整列表见 - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

这对于 NodeJS 的 Windows 用户来说仍然很痛苦,因为它假定您安装了 Visual Studio 的副本,而许多最终用户永远不会拥有它。因此,我正在游说 Joyent 鼓励他们将 Web 套接字作为 CORE Node 的一部分,并可能将 GNU gcc 编译器作为 NodeJS 安装的一部分,这样我们就可以永久解决这个问题。

欢迎在以下位置添加您的投票:

关于node.js - Npm 模块安装 Visual Studio 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24546695/

相关文章:

node.js - 我的 POST API 路由执行延迟?

javascript - 从 nodejs 以 html 格式共享文件

html - Node.js Web 应用程序中的 ECONNRESET、MongoNetworkError

angularjs - 如何通过angular js传递JsonWebToken x-access-token

java - 为什么 node.js 加密模块给出的结果与 AES 加密的 Java Cipher 类不同?

mysql - Node js(Express js)Mysql读取ECONNRESET错误

mysql - 辅助方法和关联包括不处理 Sequelize

node.js - 当新的主 Node 当选后,Express 无法连接到 mongodb 副本集

javascript - 使用用户模型进行环回时出现 401 错误

javascript - 使用 Javascript 计算模式