vorpal-repl icon indicating copy to clipboard operation
vorpal-repl copied to clipboard

Should I be able to 'require' in the repl?

Open jimthedev opened this issue 10 years ago • 4 comments

Just wondering if the intended functionality is for me to be able to use require('path') or the like inside the repl?

Currently I get Error: require is not defined

jimthedev avatar Sep 11 '15 09:09 jimthedev

Really? It should definitely handle it. Can you show me exactly what you did?

dthree avatar Sep 11 '15 16:09 dthree

Sure.

Here is my setup:


// Express
var express = require('express');
var history = require('connect-history-api-fallback');
var morgan  = require('morgan');
var bodyParser = require('body-parser');

// Express App
var app = express();

// Env
var PORT     = process.env.PORT || 3000;
var NODE_ENV = process.env.NODE_ENV || 'development';

app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// Angular Http content type for POST etc defaults to text/plain at
app.use(bodyParser.text(), function ngHttpFix(req, res, next) {
  try {
    req.body = JSON.parse(req.body);
    next();
  } catch(e) {
    next();
  }
});

// Your middleware
app.use(history());
app.use(express.static('src/public'));

var api = require('./todo_api')();
app.use('/api', api);

  // Vantage Repl
var vantage = require('vantage');

var vantageServer = vantage()
 .delimiter('svr:5000~$')
 .listen(app, 5000)
 .show();

I am on node 0.12.0 and OSX.

jimthedev avatar Sep 12 '15 11:09 jimthedev

Thanks. Checking it out.

dthree avatar Sep 12 '15 16:09 dthree

Hi, same problem here. As a temporal (dirty) workaround I'm using this: global.require = require;

jesusprubio avatar Nov 24 '15 08:11 jesusprubio