1

I'm using org-mode in Spacemacs and have this code block:

#+BEGIN_SRC js :var payload=access-token-payload
let parsedPayload = JSON.parse(access-token-payload);
return parsedPayload.access_token;
#+END_SRC

Expected behavior: The code executes when I press C-c C-c

Actual behavior: I get an error saying No org-babel-execute function for js!. This should be supported since org-babel is present. I code a lot of Node and Javascript applications so Node is in my path.

1

You need to enable evaluation of js code. Section 14.7 of org manual states:

By default, only 'emacs-lisp' is enabled for evaluation. To enable or disable other languages, customize the `org-babel-load-languages' variable either through the Emacs customization interface, or by adding code to the init file as shown next:

In this example, evaluation is disabled for 'emacs-lisp', and enabled for 'R'.

(org-babel-do-load-languages
  'org-babel-load-languages
  '((emacs-lisp . nil)
    (R . t)))

The provided example is not totally clear IMHO but that works. Another way to enable a language is to require the org babel module for the language, eg here:

M-: (require 'ob-js)
  • This is strange because I was using bash, python and org code blocks without any issue, out of the box. Thanks. – Mario Gil Dec 17 '19 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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