node.js

Getting into the angular phonecat demo, in windows, and early on hit a snag.

This one was from trying to update karma, a TDD framework for angular powered by node.js

Seemed pretty straight forward from what I have learnt from node so far.

npm install karma

Nothing like error messages from an unfamiliar environment to make you sit up in your chair.

npm ERR! peerinvalid The package karma-requirejs does not satisfy its siblings'
peerDependencies requirements!
npm ERR! peerinvalid Peer karma@0.10.10 wants karma-requirejs@~0.2.0

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Dev\angularTutorial\angular-phonecat\scripts
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Dev\angularTutorial\angular-phonecat\scripts\npm-debug.log
npm ERR! not ok code 0

After I quick google search, with nothing initially, I realised I have some something really weird, that caused a error the likes of which no one has ever seen, or the solution was starting me in the face.

npm ERR! peerinvalid Peer karma@0.10.10 wants karma-requirejs@~0.2.0

...like that.

npm install karma-requirejs

Karma then installed.

However, then the test.bat as part of the angular tutorial, which runs the karma command in DOS, returned this old favourite.

'karma' is not recognized as an internal or external command,
operable program or batch file.

Before clogging up my PATH variable, the -g (--global) variable in npm install came to mind.

However this did not work, even after first uninstalling the package.

Though, this time a  Stackoverflow answer at the top of google let me know that at least this time I was not so alone.

npm install -g karma-cli

With some basic tutorials under my belt, I decided to see what cloud offered in term of node.js IDE's.

The Cloud 9 node.js IDE was my first stop, and I have to say, unlike Sublime Text with a suite of plugins, it did not leave me wearing, though I admit it's not exactly fair to compare an extensible text editor to a IDE.

While I still have much I want to try, my next investigation was into running node.js locally.

Forever was the first on my radar, which persists a running node script over server and and restarts. Devo.ps blog on their preference of PM2 then caught my attention. PM2 also offers cluster load balancing, JSON configs and few production level features has taken over in popularity.

I then came across a blog post I that, as a node newbie, I found quite useful, 7 tips for a Node.js padawan by Faisal Abid. Its recommendation to use nodemon for dev, and PM2 for production made a lot of sense, especially since PM2 is not design for windows use, time to dust off the LMDE server I usually reserve for Android ROM work.

My next search, being the visual guy I am, I was looking for an all in one local web dashboard, process monitoring, server management & performance monitoring app. This stackoverflow answer, resulted in the context switch I needed from my IIS heavy background to the lightweight node.js space. What I need is not a monitoring app, but a node.js script, or a plugin or two to run on a second port, which monitors the first, as well as Finally, PM2 or whatever else i'd like to keep an eye on.

There also seems to be quite a market for node monitoring apps, such as nodetime and strongops, let alone what the cloud hosting apps themselves offer. Seems as though I am putting the cart before the horse, as I would suspect it best to rule out if an app would use cloud hosting before trying to reinvent the wheel in term of monitoring.

With that small exploratory tangent into the node.js space complete, it's back to Cloud 9 until I get a chance to compare it to Codeenvy, CompilrKoding, and whatever else enters this rapidly growing space between now and then.

2 Comments

Have been working through the node.js via Learn you node tutorials and thought it a good opportunity to see if I could get a node.js auto complete/hint plugin.

Unfortunately the nodejs plugin is no longer active,. and it did not seem to be namespace aware, that is, it would not narrow the filter based on the namespace. Entering 'a..' gave the same filtered list as 'fn.a...', as one of the motivations of my search was to have an easy way to explore namespaces, it wasn't going to cut it.

Enter SublimeCodeIntel. I was hoping to kill two birds with one stone and find something that turned a XSD into a hint file for  XML. This would help me edit web.config files using the DotNetConfig.xsd, though no luck. Will have to resume that search another time.

SublimeCodeIntel worked fine out of the box, until I started editing the settings. Saving the user preferences without the encompassing curly braces around the all my setting crashes SublimeText, hard. Only Ctrl-Alt-Del could kill her, though the Unexpected trailing characters message did point me to the first line that helped me get that sorted quickly.

The next issue was enabling the node.js autocomplete. The sublime forums almost got me there, though it was a post right at the bottom on an old bug on the plugin's github page that illuminated what I was missing. There are two parts, firstly, codeintel_syntax_map.

"codeintel_syntax_map": {
  "JavaScript": "Node.js"
}

And my missing piece of the puzzle, javascriptExtraPaths

"codeintel_config": {
  "JavaScript": {
    "javascriptExtraPaths":["./Packages/SublimeCodeIntel/libs/codeintel2/lib_srcs/node.js"],
    "codeintel_scan_files_in_project": false,
    "codeintel_max_recursive_dir_depth": 2
  }
}