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
 (require 'tern-auto-complete)
(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.

October 19, 2015

What is this nodejs Thing You Speak of?

Filed under: Programming — Cranky Sysadmin @ 7:19 am

A very long time ago, I was interested in exposing javascript via apache in much the same way as mod_perl does. I got a working demo running based on (now dead) mod_snake code and the mozilla spidermonkey javascript engine. I abandoned the project due to other interests, but I still like the idea of serverside javascript. Now there is nodejs, which is a javascript engine based on the v8 engine. It has a reasonably complete standard library, and a nice package manager called npm. There is even a (old outdated) mod_node if you really want to hook it into apache. Node looks like it’s architected well and has good performance. If I were to judge a book by its cover I’d say node is worth learning and using.

Powered by WordPress