【问题标题】:How do I install websocket module for Node.js on Debian VPS?如何在 Debian VPS 上为 Node.js 安装 websocket 模块?
【发布时间】:2012-09-12 02:30:12
【问题描述】:

我已经成功安装了 Node.js,现在我想安装这里找到的 websocket 模块:https://github.com/Worlize/WebSocket-Node

从 root 用户,我运行了以下命令:

 npm install websocket

抛出的错误是:

[websocket v1.0.7]

Native code compile failed!!

On Windows, native extensions require Visual Studio and Python.

On Unix, native extensions require Python, make and a C++ compiler.

Start npm with --websocket:verbose to show compilation output (if any).

我应该发出什么命令来安装这个 websocket 模块及其要求?

编辑: 当我运行sudo apt-get install gcc make

我收到这条消息:

正在阅读包裹清单...完成 构建依赖树 读取状态信息...完成 gcc 已经是最新版本了。 gcc 设置为手动安装。 make 已经是最新版本了。 0 个已升级,0 个新安装,0 个要移除,44 个未升级。

尝试安装 WebSocket 时出现同样的错误。

【问题讨论】:

    标签: node.js websocket debian vps


    【解决方案1】:

    如果您看到 install.js,则此错误是因为您遇到了 node-gyp 问题。 尝试“sudo npm install -g node-gyp”并再次运行您的命令。

    【讨论】:

      【解决方案2】:

      确保您已经安装了 python、make 和 gcc。 默认情况下应该已经安装了 Python。 您可以使用以下命令以 root 身份安装 gcc 和 make:

      apt-get install gcc make
      

      【讨论】:

      • 奇怪,我仍然遇到与上述相同的错误。我将添加到原始帖子中。
      • 出现同样的错误,另外我尝试了-g和link命令。
      • 您可以尝试使用此命令安装它吗:npm install websocket --websocket:verbose 然后您应该会看到更好的错误消息。
      • 谢谢!我重新启动了服务器,它工作了。但是我无法通过在我的其他用户上运行来找到 websocket 模块。我知道为什么,我将通过重置我的 VPS 来正确地重新安装节点。这是一次很棒的学习经历,再次感谢。
      【解决方案3】:
      apt-get g++
      

      解决了我的问题,非常好!

      【讨论】:

        【解决方案4】:

        我的问题:python 版本。我已经安装了 python 2.4.3 而不是 python 2.7(websocket 需要)。

        install python2.7 使用 ma​​ke altinstall 并创建一个符号链接来替换 python 脚本:

        ln -s /usr/local/bin/python2.7 /usr/bin/python
        

        对我有用:

        # npm install websocket --websocket:verbose
        
        [websocket v1.0.8] Attempting to compile native extensions.
        gyp http GET http://nodejs.org/dist/v0.10.15/node-v0.10.15.tar.gz
        gyp http 200 http://nodejs.org/dist/v0.10.15/node-v0.10.15.tar.gz
        make: Entering directory `********/node_modules/websocket/build'
          CXX(target) Release/obj.target/validation/src/validation.o
          SOLINK_MODULE(target) Release/obj.target/validation.node
          SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
          COPY Release/validation.node
          CXX(target) Release/obj.target/xor/src/xor.o
          SOLINK_MODULE(target) Release/obj.target/xor.node
          SOLINK_MODULE(target) Release/obj.target/xor.node: Finished
          COPY Release/xor.node
        make: Leaving directory `*******/node_modules/websocket/build'
        [websocket v1.0.8] Native extension compilation successful!
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-05-15
          • 2012-07-22
          • 2016-12-10
          • 2021-12-14
          • 1970-01-01
          • 2016-02-29
          • 2011-12-16
          相关资源
          最近更新 更多