Node errors encountered in learning and using 1

learn Node.js and use it immediately. Encounter the first unsolvable error

//npm install utils
var utils = require("utils"),
EventEmitter = require("events").EventEmitter;

var Server = function(){
  console.log("init");
}

utils.inherits(Server, EventEmitter);

var s = new Server();
s.on("abc", function(){
  console.log("abc");
});

s.emit("abc");

error message

TypeError: utils.inherits is not a function

excuse me, where is the problem here?

Mar.05,2022

nodejs comes with util , and there is no s


with import utils from 'utils'


there are two similar
if you are talking about this http://shouce.jb51.net/nodejs., then you have a problem.
if this is the case, https://www.npmjs.com/package., there is really no inherits method.


var utils = require ('utils')

Menu