npm -g update disaster! npm no longer runs

I’m running a BBB with the Linux beaglebone 3.8.13 #1 SMP Thu Sep 12 10:27:06 CEST 2013 armv7l GNU/Linux image, fully opkg upgrade-ed. In an attempt to sort out some module issues, I ran npm -g update. This gave various error messages, interspersed in the usual voluminous output. There were still problems, so I ran npm again. Now it fails every time:

root@beaglebone:~# npm

module.js:340

throw err;

^

Error: Cannot find module ‘qs’

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. (/usr/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/request/request.js:8:10)

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)

It looks like the qs package required by request is missing. Without it, I can’t install it.

How can I get out of this situation, short of re-flashing the eMMC? (again!)

I hope someone can help

Thanks,

Max