vorpal-repl
vorpal-repl copied to clipboard
Should I be able to 'require' in the repl?
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
Really? It should definitely handle it. Can you show me exactly what you did?
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.
Thanks. Checking it out.
Hi, same problem here. As a temporal (dirty) workaround I'm using this:
global.require = require;