NPM - 无法安装 socket.IO [英] NPM - Can't install socket.IO
问题描述
我正在尝试使用 npm 在 windows 上安装 socket.io,以便在 nodeJS 服务器上使用.
I am trying to install socket.io on windows with npm for use on a nodeJS server.
首先,当我输入npm install socket.IO"时,我在日志中出现了一个关于 python 和 node-gyp 的错误.我安装了python 2.7.3并设置了环境变量.
First, when I typed "npm install socket.IO" i had an error in the log saying something about python and node-gyp. I installed python 2.7.3 and set the environment variables.
现在我遇到了一个新错误,它与visual studio有关(VS与npm有什么关系?与编译器有关?).
Now I got a new error, which has something to do with visual studio (what the hell does VS have to do with npm ? Is it about the compiler? ).
错误和这里一样 npm 安装某些软件包(sqlite3、socket.io)在 Windows 7 上失败并显示错误 MSB8020但是,当我在答案中使用该选项而不是错误时,它会告诉我有关可能的数据丢失 (c4267) 的一些信息,但不会记录任何错误.
The error is the same as here npm install for some packages (sqlite3, socket.io) fail with error MSB8020 on Windows 7 But when I use the option in the answer instead of the error it tells me something about a possible data loss (c4267) but doesn't log any error.
然后当我启动我的应用程序时,它告诉我仍然找不到模块 socket.io这可能来自什么?
Then when I start my app, it tells me cannot find module socket.io still What could this come from ?
哦,当我执行 npm config get root 时,它告诉我未定义"是否与它有关?我应该全局安装模块还是本地安装模块?
Oh and also when i do npm config get root it tells me "undefined" could it have anything to do with it ? Should I install the modules globally or locally ?
推荐答案
Socket.IO 的依赖树中至少有一个包是 C/C++ 插件,需要在安装时在系统上编译.而且,由于它是一个依赖项,如果安装不成功,Socket.IO 也不会.
At least one of the packages in Socket.IO's dependency tree is a C/C++ addons which needs to be compiled on your system as it's installed. And, since it's a dependency, if it doesn't succeed in installing, neither will Socket.IO.
为了启用跨系统编译,Node.js 使用 node-gyp
作为它的构建系统.您需要将其安装为全局包:
To enable cross-system compilation, Node.js uses node-gyp
as its build system. You'll need to have it installed as a global package:
npm install -g node-gyp
以及安装其依赖项.删减版:
- Python 2
- C/C++ 编译器/构建工具
- 对于 Windows,Microsoft Visual Studio 2013(C++ 或 Windows 桌面)(速成版)
- 对于 64 位,可能需要 Windows 7 64 位 SDK
然后,您应该能够将 Socket.IO 作为本地包安装,以便您可以
要求
它:Then, you should be able to install Socket.IO as a local package so you can
require
it:npm install socket.io
这篇关于NPM - 无法安装 socket.IO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 对于 Windows,Microsoft Visual Studio 2013(C++ 或 Windows 桌面)(速成版)