1

In many of my applications I use the NPM package.json to manage my build tools. I've found that one of the modules probably has a bug. I'd like to debug it but I don't know how to debug the application in the context of the build task.

Specifically, in this case, I'm using Ember-cli. Ember-cli has a build command: ember build that builds the app using a bunch of modules defined in package.json such as ember-cli-compass-compiler.

I want to be able to add breakpoints or some sort of logging at certain points of the ember-cli-compass-compiler module that are triggered when the build runs so that I can inspect values.

EasyCo
  • 2,036
  • 20
  • 39

2 Answers2

0

Looks like according to https://github.com/ember-cli/ember-cli/blob/c8934ab0f2eb3aab03ce4557a36c317887245b95/lib/models/project.js as part of the build step is to look at the project's package.json and check for ember-cli-compass. After which, it would presumably use your project's local version of ember-cli-compass-compiler to execute some tasks. The simplest way to debug it is to use console.log() and log various points inside ember-cli-compass-compiler to see what code paths are being triggered.

The codebase for the compiler is very small, and you'd probably want to start with the index.js https://github.com/quaertym/ember-cli-compass-compiler/blob/master/index.js

Yuri Zarubin
  • 11,439
  • 4
  • 30
  • 33
  • Thanks @yazarubin... What about node-inspector? I tried using it like this: `node-debug node_modules/ember-cli/bin/ember build` and I added a `debugger;` in the `index.js` of `ember-cli-compass-compiler`. It pauses execution but it pauses it in `module.js` instead of the `index.js`... Not sure what that's all about. – EasyCo Feb 12 '15 at 07:26
  • Can't comment on node-inspecter, I've never used it. I've debugged countless modules and console.log is the only thing I've ever needed/used. – Yuri Zarubin Feb 12 '15 at 16:57
0
node --inspect-brk ./node_modules/.bin/ember build

will launch the program in the debugger. After you attach, it will stop at the entrypoint - if you haven't already set your breakpoints that is a convenient time to set them.

You may have to skip through some "false" errors that are normal and are being handled correctly - they seem random and can be confusing if you are not expecting them. You can uncheck "caught exceptions" to avoid that, but then you could miss important caught exceptions in ember which occur before your breakpoint(s).

Craig Hicks
  • 2,199
  • 20
  • 35