kof/node-argsparser — Issue #5: Error: Cannot find module 'argsparser'
Author: cburgmer
Created: 2011-11-18 14:13:46+00:00
State: open

I setting up node-qunit, and would receive a traceback:

$ ./bin/qunit

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'argsparser'
at Function._resolveFilename (module.js:317:11)
at Function._load (module.js:262:25)
at require (module.js:346:19)
at Object. (/home/christoph/.node_libraries/.npm/qunit/0.1.5/package/bin/cli.js:4:12)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at require (module.js:346:19)
at Object. (/home/christoph/bin/qunit@0.1.5:11:18)

In node I got the following error trying to require argsparser:

> require("argsparser")
Error: Cannot find module 'argsparser'
at Function._resolveFilename (module.js:317:11)
at Function._load (module.js:262:25)
at require (module.js:346:19)
at [object Context]:1:1
at Interface. (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream. (readline.js:73:12)

I fixed this by creating the following file under ` /home/christoph/.node_libraries/argsparser@0.0.6/index.js` (I stole this from the cssom package):

#!/usr/bin/env node
// generated by npm, please don't touch!
var dep = require('path').join(__dirname, "./../.npm/argsparser/0.0.6/node_modules")
var depMet = require.paths.indexOf(dep) !== -1
var bundle = dep.replace(/node_modules$/, 'package/node_modules')
var bundleMet = require.paths.indexOf(bundle) !== -1
var from = "./../.npm/argsparser/0.0.6/package/index"

if (!depMet) require.paths.unshift(dep)
if (!bundleMet) require.paths.unshift(bundle)
module.exports = require(from)

if (!depMet) {
var i = require.paths.indexOf(dep)
if (i !== -1) require.paths.splice(i, 1)
}
if (!bundleMet) {
var i = require.paths.indexOf(bundle)
if (i !== -1) require.paths.slice(i, 1)
}

I am new to node.js & npm so not sure if this is the right spot to report.