【问题标题】:Executing nodeJS application on DigitalOcean server在 DigitalOcean 服务器上执行 nodeJS 应用程序
【发布时间】:2017-11-17 21:51:46
【问题描述】:

我在 DigitalOcean 服务器上运行 Ubuntu 14.04.5 LTS。

nodeJS 已经安装。 我将我的应用程序文件上传到 /家/哭

申请文件是 /home/cry/hello.js

我尝试通过运行来执行我的应用程序 节点hello.js

我收到此错误

The program 'node' can be found in the following packages:
 * node
 * nodejs-legacy
Try: apt-get install <selected package>

如果有人能告诉我这里出了什么问题以及如何解决它,那就太好了。

【问题讨论】:

  • 以 nodejs hello.js 运行
  • 您只需要在nodejsnode 之间创建一个符号链接。检查here怎么做。

标签: javascript node.js ubuntu nodes digital-ocean


【解决方案1】:

检查which node 将返回节点路径。

使用它来运行您的文件。

user@user-dev:~$ which node
/usr/bin/node
user@user-dev:~$ /usr/bin/node hello.js

或尝试使用nodejs hello.js运行

【讨论】:

    【解决方案2】:

    尝试使用:

    user@user: nodejs  youFile.js
    

    如果您不想使用“node”而不是“nodejs 命令”,您应该执行以下操作:

    user@user: ls -s /user/bin/nodejs /user/bin/node 
    

    然后你可以直接使用“node”作为命令行

    【讨论】:

      【解决方案3】:

      如何在 Ubuntu 14.04 上设置用于生产的 Nodejs 应用程序

      您可以通过以下链接了解有关数字海洋的完整指南

      link

      希望这可以解决您的问题

      【讨论】:

        【解决方案4】:

        您首先需要从 deb.nodesource 安装 node.js。方法如下:

        curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
        sudo apt-get install -y nodejs
        

        然后你可以使用“node hello.js”或其他任何东西。

        当您在 ubuntu 14.04 上首次使用 apt-get 安装 nodejs 时,您安装的是 0.12 或一些过时的 node.js 版本,并且该版本的可执行文件是“nodejs”,而不是“node”。

        你也可以尝试使用它,但我猜你会遇到 0.12 的问题,所以我认为你应该使用更高的版本,比如 7 或 8。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2023-01-16
          • 2018-09-24
          • 1970-01-01
          • 2011-05-22
          • 2019-09-23
          • 1970-01-01
          • 1970-01-01
          • 2012-11-10
          相关资源
          最近更新 更多