linux重启后,nodejs消失了

 捡到宝开封 发布于 2023-02-06 16:16

我刚用安装成功的nvm安装了nodejs版本0.10.14.在安装nodejs之前,我安装了zeromq 2.2.0版.

出于测试目的,我试图在下面运行一个基本的pub示例.

var zmq = require('zmq');
var socket = zmq.socket('pub');

console.log("Binding socket on port 8800...");

socket.bind('tcp://localhost:8800', function(err){
    if(err){
        console.log(err)
    } else{
        console.log("listening on port 8800");
    }
});
socket.send("hello this is testServer2 on port 8800...");

但这是投掷错误 -

events.js:72
    throw er; // Unhandled 'error' event
          ^
TypeError: Socket is busy
    at Socket._ioevents (/home/zishan/node_modules/zmq/lib/index.js:198:22)
    at Socket._flush (/home/zishan/node_modules/zmq/lib/index.js:343:23)
    at Socket.send (/home/zishan/node_modules/zmq/lib/index.js:318:42)
    at Object. (/home/zishan/newsURLCollector/testServer2.js:16:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

端口8800已经使用ufw打开了.

我试着谷歌搜索套接字繁忙的错误,但没有运气,我认为重新启动Ubuntu是好的,问题变得更糟.当我重新登录并尝试再次运行上述示例时,系统会抛出消息:

zishan@news01:~/newsURLCollector$ node testServer2.js

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

为什么地球上的工作节点停止工作并且无法找到节点.然后我按照系统提示,并在下面做了sudo apt-get install节点的结果:

zishan@news01:~$ sudo apt-get install node
[sudo] password for zishan:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libpgm-5.1-0
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed
  node
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/1,284 B of archives.
After this operation, 38.9 kB of additional disk space will be used.
Selecting previously unselected package node.
(Reading database ... 66172 files and directories currently installed.)
Unpacking node (from .../node_0.3.2-7.4_all.deb) ...
Processing triggers for man-db ...
Setting up node (0.3.2-7.4) ...
zishan@news01:~$ node -v

然后我试图找到节点版本,但没有发生任何事情,我现在没有得到一个节点提示,但当我做"哪个节点"它说 - /usr/sbin/node

重启后我不知道出了什么问题.任何人都可以解释一下.

1 个回答
  • 当NVM加载时,它会加载当前标记为的任何版本的Node default.

    nvm install v0.10.14将安装v0.10.14并告诉NVM通过键入node您当前的终端使其可供您使用,但它不会将其标记为默认值,因为您可以轻松安装5个版本的节点.NVM也没有像记得你最后使用的Node版本那样花哨的东西,因为你可能有10个终端打开,每个终端都有不同的版本.

    所有你需要做的就是nvm use v0.10.14告诉你的终端暴露v0.10.14node.

    在你的情况下,最好的办法可能是将其设置为默认值,因此它将在每次重启和新终端上使用它:

    nvm alias default v0.10.14
    

    正如你已经想到的那样,通过跑步

    apt-get install node
    

    你安装了这个:http://packages.qa.debian.org/n/node.html

    我现在也会推荐你apt-get remove nodejs并坚持下去nvm.这些deb软件包相当快速地过时,使用NVM可以让您更轻松地跟上.

    2023-02-06 16:18 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有