I can't seem to get emacs to recognize node stacktraces. As you can see, I've added what I think is a valid regular expression to compilation-error-regex-alist and compilation-error-regex-alist-alist, but it still does not match, and brings up the file selection dialog if I try to navigate to the next error.

https://cloud.githubusercontent.com/assets/4205/18681080/0cb6630a-7f2c-11e6-9c5c-aeaf62f651a6.pngprompting for the file containing the error

It appears that it's thinking of test/state-test.js:127 as the file name:

Is there a way to debug the process by which errors are recognized so I can see why it is not matching?

I've run regex in the re-builder showing the file and so it would appear that the line and column groups match:

re-builder matching the desired regex

Here is the lisp code that attempts to add the node regex:

(add-to-list 'compilation-error-regexp-alist 'node)

(add-to-list 'compilation-error-regexp-alist-alist
         '(node "^[ \f\n ]*at.+(\(.+\):\([[:digit:]]+\):\([[:digit:]]+\))$" 1 2 3))

The compilation buffer:

-*- mode: compilation; default-directory: "~/Code/microstates.js/" -*-
Compilation started at Tue Sep 20 12:09:31

npm t
> [email protected] test /Users/cowboyd/Code/microstates.js
> mocha test/index.js


  The Basic Opaque State
    wrapping an object value in a State
      with pre-defined properties
[0G        1) has those properties by default

  0 passing (38ms)
  1 failing

  1) The Basic Opaque State wrapping an object value in a State with pre-defined properties has those properties by default:
      AssertionError: expected undefined to be an instance of State
      at Context.<anonymous> (test/state-test.js:127:33)

[?25h[?25h[1A[0G[?25h[0Gnpm ERR! Test failed.  See above for more details.

Compilation exited abnormally with code 1 at Tue Sep 20 12:09:33

2 Answers 2


Answer came in via twitter from hero @jscalterego https://twitter.com/cowboyd/status/778287337952247808

Apparently the problem is that in the re-builder, I was using "string" regex syntax vs "read" syntax, and so the regular expression was not properly formed. I'm not super well-versed on the differences between the various syntaxes. I imagine that's a whole other line of inquiry, but the winning regex was

'(node "at [^ ]+ (\\(.+?\\):\\([[:digit:]]+\\):\\([[:digit:]]+\\)" 1 2 3)

which worked very well.


compile-goto-error didn't work for me when I tried the answer from the tweet -- it seems like the line number was being captured by the filename group. From this emacs.d I tried:

(setq compilation-error-regexp-alist-alist
        ;; Tip: M-x re-builder to test this out
        (cons '(node "^[ ]+at \\(?:[^\(\n]+ \(\\)?\\([a-zA-Z\.0-9_/-]+\\):\\([0-9]+\\):\\([0-9]+\\)\)?$"
                           1 ;; file
                           2 ;; line
                           3 ;; column

which worked perfectly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.