3. November 2012

Cannot find module ‘couchapp’ – solution for Linux and Windows

It is possible to create HTML5/CouchDB application using Node.js with tool Couchapp.

You can find nice totorial at RelaxTV.

The first step: install Couchapp:

npm -g install couchapp

Now you have command couchapp and you can create boilerplate:

coachapp boiler blog

This works fine, but when you want to publish this application to CouchDB server you can see weird error:

PS C:\idea\couch\blog> couchapp push app.js http://localhost:5984/blog
module.js:340
 throw err;
 ^
Error: Cannot find module 'couchapp'
 at Function.Module._resolveFilename (module.js:338:15)
 at Function.Module._load (module.js:280:25)
 at Module.require (module.js:362:17)
 at require (module.js:378:17)
 at Object.<anonymous> (C:\idea\couch\blog\app.js:1:79)
 at Module._compile (module.js:449:26)
 at Object.Module._extensions..js (module.js:467:10)
 at Module.load (module.js:356:32)
 at Function.Module._load (module.js:312:12)
 at Module.require (module.js:362:17)

People at node.couchapp discussion suggest that you should set NODE_PATH. This path should point to the place where node stores modules. npm shows this path during installation of module.

Fix for Linux:

export NODE_PATH=/usr/local/lib/node_modules

Node is using little bit different storage on Windows, it stores data into ~\AppData\Roaming\npm.

Fix for Windows Powershell (ConEmu):

$env:node_path="$home\AppData\Roaming\npm\node_modules"

If you want to persist change for PowerShell, then you can put this line into: Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

5. August 2012

Console2 for Windows – semi-transparent NodeJS shell, PowerShell or cmd

Update: I switched from Console2 to ConEmu. ConEmu is far more advanced.

Console2 is great little front-end for Windows. It makes PowerShell even more usable. It’s very flexible and you can configure console window to behave like terminal window on MacOS or Linux. It has also support for transparency. It’s simply great. No need to add any more words. Just try it.

I’d like to add few more hints.

Enable transparancy

  • Go to Settings – Appearance – More…
  • Select Window transparency – Alpha
  • Change alpha level of Active and Inacative window.

Result:

Copy on left mouse button click, paste on middle button click

Default configuration of mouse is not very useful. You have to press Shift and Left Mouse to select and copy text. Make small adjustment:

  • Settings – Hotkeys – Mouse
  • Change: Copy/clear selection to Left + Shift
  • Change: Select text to Left

Use Console2 as front-end for NodeJS

You can use Console2 to invoke also NodeJS shell. Just create Tab definition for NodeJS.

  • Go to Settings – Tabs
  • Add NodeJS and set Shell to: “C:\Program Files (x86)\nodejs\node.exe”

Create new Tab with NodeJS profile:

Awesome 🙂