Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open a console to interact with Express app?

How can I open a console to interact with my Express app?

I am trying to test whether some methods work to create a model. I'm using SequelizeJS, but that shouldn't matter for the answer to this question.

I am used to Rails where I can do $ heroku run rails console then interact with the models in my app. I would like to do the same in Express.

like image 602
Don P Avatar asked Aug 30 '15 01:08

Don P


People also ask

How do I open node JS console?

To launch the REPL (Node shell), open command prompt (in Windows) or terminal (in Mac or UNIX/Linux) and type node as shown below. It will change the prompt to > in Windows and MAC. You can now test pretty much any Node.


1 Answers

  • Make your app export the express instance (module.exports = app)
  • Run node, which will put you in a REPL loop
  • Require your project: var myApp = require('./app')
like image 145
Nobody Avatar answered Sep 21 '22 10:09

Nobody