node.jsexpressmikrotik

Mikronode with Express Js: TypeError: _sentence$.get(...).do is not a function


I want to use Mikronode with Express Js but get an error TypeError: _sentence$.get(...).do is not a function for the first run.

I generate the application skeleton using Express generator and try the example Mikronode code from wiki.mikrotik.com

This is the code:

var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var api = require('mikronode');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);

// Mikronode example code
var connection = new api('192.168.0.1','admin','password');
connection.connect(function(conn) {

   var chan=conn.openChannel();

   chan.write('/ip/address/print',function() {
      chan.on('done',function(data) {

         var parsed = api.parseItems(data);

         parsed.forEach(function(item) {
            console.log('Interface/IP: '+item.interface+"/"+item.address);
         });

         chan.close();
         conn.close();

      });
   });
});

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};

    // render the error page
    res.status(err.status || 500);
    res.render('error');
});

module.exports = app;

If i run the code above, the output show an error:

/Users/me/Desktop/mknode/node_modules/mikronode/dist/mikronode.js:474
                _parsed$.set(this, _sentence$.get(this).do(function (d) {
                                                          ^

TypeError: _sentence$.get(...).do is not a function
    at new SocketStream (/Users/me/Desktop/mknode/node_modules/mikronode/dist/mikronode.js:474:52)
    at MikroNode.connect (/Users/me/Desktop/mknode/node_modules/mikronode/dist/mikronode.js:330:30)
    at Object.<anonymous> (/Users/me/Desktop/mknode/app.js:31:12)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
error Command failed with exit code 1.

My package.json:

{
  "name": "mknode",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "cookie-parser": "~1.4.3",
    "core-decorators": "^0.20.0",
    "debug": "~2.6.9",
    "express": "~4.16.0",
    "http-errors": "~1.6.2",
    "mikronode": "^2.3.11",
    "morgan": "~1.9.0",
    "pug": "2.0.0-beta11",
    "rxjs": "^6.2.2"
  }
}

Anyone can help me to solve this?


Solution

  • solved by installing "rxjs": "^5.3.0"