The Cranky Sysadmin A world of technology, fun, and ignorant rants.

October 26, 2015

Developing Node in Emacs on Ubuntu

Filed under: Uncategorized — Cranky Sysadmin @ 8:00 am

I am impressed by my first impressions of node.js. It feels very Unix-like. If you want to develop node in emacs, a good place to start might be Truong TX blog. My setup differs a bit from his. You can find my whole emacs environment on github. Outside of emacs, you of course should have node and npm installed. I then installed Tern with ‘npm install tern -g’. The relevant snip from my emacs init is below

;; if you aren't running a package manager, you'll need to
;; require js2-mode, ac-js2-mode, tern-mode, tern-auto-complete
;;
;; javascript using js2-mode and tern
(add-hook 'js2-mode-hook 'ac-js2-mode)
(add-hook 'js2-mode-hook (lambda() (tern-mode t)))
;; I have tern in a non-standard directory
(setq tern-command '("/home/FOOFOO/node/bin/node" "/home/FOOFOO/.node_modules/bin/tern"))
(eval-after-load 'tern
 '(progn
 (require 'tern-auto-complete)
 (tern-ac-setup)))
(add-to-list 'auto-mode-alist '("\\.json\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; if you don't want to warn on missing semicolons,
;; uncomment the following
;; (setq js2-strict-missing-semi-warning t)

I don't know why I never used yasnippet before, but I've been wasting a lot of time without it. Add the following above any auto-complete sections:
(require 'yasnippet)
(yas-global-mode 1)

And with that, you should be able to settle into some nice node tutorials.

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Powered by WordPress