Tuesday, March 24, 2020

ob-js, javascript, nodejs in org babel in Emacs

1. install from default packagge
  > refer from > How to Install Latest Nodejs on LinuxMint 19/18
 ->  https://tecadmin.net/install-latest-nodejs-npm-on-linux-mint/

> install default pacakge with apt-get
sudo apt-get install nodejs

node -v
: v8.xx.x

> remove
sudo apt-remove nodejs
sudo apt remove nodejs-doc

sudo apt remove npm

 sudo apt-get autoremove

2. install from nodejs and github node 10, node 12
https://nodejs.org/en/download/package-manager/
https://github.com/nodesource/distributions/blob/master/README.md

>Node.js v10.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs


- Node.js v12.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

- check
node -v
v12.16.1

npm -v
6.13.4


3. Emacs
  Org-babel-js

3-1. if yo got some eorr like following
https://emacs.stackexchange.com/questions/55690/org-babel-javascript-error

#+begin_src js
  console.log("Hello");
#+end_src

/tmp/babel-8kqQwQ/js-script-shBzKH:1
require('sys').print(require('sys').inspect(function(){
....

+begin_src js :results output
console.log("Hello, World!");
#+end_src

#+RESULTS:
: Hello, World!
(then add org header)

#+PROPERTY: header-args:js :results output


#+begin_src js
console.log("Hello");
#+end_src

#+RESULTS:
: Hello

No comments:

Pranten

 Pranten