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? ).
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时,它会告诉我未定义",这与它有什么关系吗? 我应该在全局还是本地安装模块?
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桌面)(Express版)
- 对于64位,可能需要Windows 7 64位SDK
- Python 2
- C/C++ Compiler / Build Tools
- For Windows, Microsoft Visual Studio 2013 (C++ or Windows Desktop) (Express edition)
- For 64-bit, may need Windows 7 64-bit SDK
然后,您应该能够将Socket.IO作为本地软件包安装,这样您就可以
require
了: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屋!
- For Windows, Microsoft Visual Studio 2013 (C++ or Windows Desktop) (Express edition)
- 对于Windows,Microsoft Visual Studio 2013(C ++或Windows桌面)(Express版)