I have some existing JS code which I am releasing as an NPM package. Let's call it "my-pkg". I've created the package.json and installed my new local package. My package consists of these files:
- my-pkg.js
- package.json
my-pkg.js
function ping() {
console.log("Hi!");
}
package.json
{
"name": "my-pkg",
"version": "1.0.0",
"description": "My test package.",
"main": "my-pkg.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Me",
"license": "ISC"
}
I try to use my package like this:
npm install .\my-pkg
node
> var myPkg = require("my-pkg");
undefined
> myPkg.ping();
TypeError: undefined is not a function
Note that this is on Windows 8 in an elevated command line with Node.JS v0.12.2. I am looking to expose existing JS functionality, not write a brand new NPM package. What am I missing here?
my-pkg.js?