Skip to content
Pulkit Singhal edited this page Aug 11, 2015 · 8 revisions
  • What is loopback-console and what it isn't?

    • The console exists kind of like a single extended web-based request ... it’s not exactly a request, but that’s essentially how it’s operating. There’s a dummy context created which simulates the web context. But you don’t have any of the web handles like http req/res ... so it’s not really for testing remote methods (though that’s something that should be added maybe), it’s more for testing models.
  • Is it a bad idea to install loopback-console globally?

    • You can quickly debug any number of loopback projects without tinkering with the local setup of each one

$ npm install -g loopback-console /Users/xxx/.nvm/v0.xx.xx/bin/loopback-console -> /Users/xxx/.nvm/v0.xx.xx/lib/node_modules/loopback-console/bin/loopback-console loopback-console@0.1.0 /Users/xxx/.nvm/v0.xx.xx/lib/node_modules/loopback-console ├── repl.history@0.1.3 ├── app-root-path@1.0.0 └── lodash@3.9.3 $ cd myProject $ loopback-console . ```

  • But this means you might miss-the-chance-to or forget-to leverage the integrated approach which comes with a local install.

$ cd myProject $ npm install --save loopback-console $ $(npm bin)/loopback-console .

  *  Use `--save` instead of `--save-dev` because it’s also very useful as an admin console on production. This is why it was originally built!
* What's all this `$(npm bin)` business? Am i supposed to replace or substitute that?
* No! `$(npm bin)` will be automagically resolved by your shell. For example:

 ```
$ cd myProject
$ echo $(npm bin)
/Users/xxx/dev/myProject/node_modules/.bin

$ cd myProject
$ ls -alrt $(npm bin)/loopback-console
/Users/xxx/dev/myProject/node_modules/.bin/loopback-console -> ../loopback-console/bin/loopback-console
 ```
* Which is why setting up your package.json with:

 ```
 "scripts": {
     "console": "$(npm bin)/loopback-console ."
 }
 ```
 resolves the local path and allow you to execute `npm run console` for quick access.

Clone this wiki locally