javascriptemacsorg-modeorg-babel

no org-babel-execute function for javascript in emacs org-babel


I have added the following code to my init file. But I still get the error.

(org-babel-do-load-languages
      'org-babel-load-languages
      '((js . t)))

I noticed in Babel supported Languages, it says javascript requires node.js. So I download node.js and added the folder to my Environment PATH. However, I got the same error.

So how could I run javascript in org-babel?


Solution

  • Thanks for @manandearth's link, I partly sovle this question:

    Reason why I got the prompt is that I wrote the wrong src block identifier in my case.

    Since I write (js . t), so it should like

    #+BEGIN_SRC js
    console.log("hello world");
    #+END_SRC
    

    Not

    #+BEGIN_SRC javascript
    console.log("hello world");
    #+END_SRC
    

    Possible identifiers can be found at https://orgmode.org/org.html#Languages and https://orgmode.org/worg/org-contrib/babel/languages.html.