Prerequisites

First of all lets check up does NodeJS already installed on our host:

nodejs --version
v0.10.29

Activation

In order to use JS inside Babel you'll need to activate its support. Find in your .emacs or .init strings with Babel's supported languages:

(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t)
   (emacs-lisp . t)
   (shell . t)
   (js . t)
   (ditaa . t)
   (plantuml . t)
   (sqlite . t)
   ))

and ensure that JS is already included. Otherwise you should add the necessary string and evaluate the region by marking it C-SPC and execution M-x eval-region

Testing

Try to copy and paste code snippet below into your org file and evaluate it by yourself. Put the pointer between #+BEGIN_SRC and #+END_SRC and type C-c C-c to get results.

#+BEGIN_SRC js :cmd "nodejs" :results output
  console.log("Hello World!");
#+END_SRC

#+RESULTS:
: Hello World!

Conclusion

Have a fun



blog comments powered by Disqus

Published

15 October 2016

Categories

emacs javascript nodejs

Tags