Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7977793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:18:36+00:00 2026-06-04T09:18:36+00:00

I have a small sample program http://pastebin.com/5gFkaPgg that serves a REPL to a client

  • 0

I have a small sample program http://pastebin.com/5gFkaPgg that serves a REPL to a client over TCP. Acording to the docs http://nodejs.org/api/repl.html I have by eval function (lines 11-13) setup correctly, but the callback object is not a function. What am I misinterpreting in the docs?

  callback(null,result);
  ^
TypeError: object is not a function

Can’t Answer my own question…

According to https://github.com/joyent/node/blob/master/lib/repl.js
the signature is

function(code, context, file, cb) {
  //code
  cb(err, result);
}

Let me know if there is a more appropriate solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:18:38+00:00Added an answer on June 4, 2026 at 9:18 am

    The error and the signature tells me that the callback was given as its arguments (code, context, file, cb) but expected as its arguments (code, cb) and thus context was bound to cb and as context is not a function, the error was produced.

    You need to do is change the argument list of the callback given to repl.start to:

    function(cmd, context, file, callback) {
    

    or use the common:

    function(cmd) {
      var callback = arguments[arguments.length-1]; // get the last argument
    

    Code with the second option as it introduces no new names:

    var net = require('net');
    var repl = require('repl');
    
    function main() {
      var clients = [];
    
      net.createServer(function(socket) {
        clients.push(socket);
    
        repl.start(">", socket, function(cmd) {
          var callback = arguments[arguments.length-1];
          var result = cmd;
    
          callback(null,result);
        });
        socket.on('end',function() {
          clients.splice(clients.indexOf(socket));
        });
      }).listen(8000);
    }
    
    main();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small program that's supposed to sample some value from a device
I have a small server program that accepts connections on a TCP or local
INTRO I have a TCP/HTTP server that supports plugins in form of Shared Libraries
I have written a small Sample program to see about Eclipse Conditional Break Points
I have written a small makefile for a few simple C programs that compiles
I have a small sample function: #define VALUE 0 int test(unsigned char x) {
I have a small code sample: private void MonitorItems() { if (someCondition) { dateSelected
I have the following parser grammar (this is a small sample): expr: ident assignop
I have small web app that generate PDF files as a report. I'm trying
I am working on a small perl program that will open a site and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.