Js2-mode is showing error when there are not registered globals. I've try this code:

(defun js2-hook ()
  ;; setting symbols instead of strings also don't work
  (dolist (global '("angular" "$" "jQuery" "console" "_" "window" "setTimeout"))
    (add-to-list 'js2-additional-externs global)))

(add-hook 'js2-mode-hook 'js2-hook)

but this don't work. How can I set globals, setting js2-additional-externs directly don't work also, because describe-variable says that this variable is automatically local when set.

  • 1
    Have you tried setting js2-global-externs? It seems that it's the variable you're looking for.
    – user12563
    Commented Feb 21, 2017 at 12:39
  • @DoMiNeLa10 Please add this as an answer.
    – caisah
    Commented Feb 21, 2017 at 19:30

1 Answer 1


It seems that the variable you want to set is js2-global-externs.

js2-additional-externs is intended for setting globals on per-buffer basis, not for all buffers with js2-mode.

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.