I am writing an npm module and testing it prior to publishing. I'm using the approach described in http://podefr.tumblr.com/post/30488475488/locally-test-your-npm-modules-without-publishing but am unable to get even a simple module to be required. Here's my package.json:
{
"name": "mystuff",
"version": "0.0.1",
"description": "",
"main": "./lib/index",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT"
}
And here's my stupid simple index.js:
'use strict'
exports.test_call = function() {
return "Hello Module"
}
I would expect I could simply require my module, but it fails:
> require('mystuff')
Error: Cannot find module 'mystuff'
at Function.Module._resolveFilename (module.js:327:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:355:17)
at require (internal/module.js:13:17)
at repl:1:1
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:281:14)
at REPLServer.runBound [as eval] (domain.js:294:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:83:20)
However, it does appear the module is installed where I expect it, and it works as expected:
> require('./node_modules/mystuff')
{ test_call: [Function] }
> require('./node_modules/mystuff').test_call()
Why am I unable to require the module? What am I missing?