Creating NPM Modules
Video Course on Real-Time HTML5 with Node.jsecosystem of modules
to create a package to publish to npm
need to create a package.json that has to be in the directory of the module file.
usually you create it in a separate directory
best to take an example file and start from there:
{
"name": "helloworld",
"version": "0.0.1-a",
"description": "hello world",
"main": "./helloworld3.js",
"keywords": [
"hello",
"world"
],
"author": "Kyle Simpson <getify@gmail.com>",
"license": "MIT"
}
it has to be a valid JSON file (keys must be surrounded in quotes,string values and arraysname
it must be uniqueversion
it must be manually versioned. semantic versioning major, minor, patch, and a fourth level for trivial updates e.g. documentation updatefunctional change: patch
once you publish a version, we have to bump the version up
if you make API changing version: minor or major
major is when you rewrite the whole
description
not required but very usefulmain
main entry point for the module keywords
not obligatory author
and license
- definitely repo
link to your github repo, where people can file bugsdependencies: {
"minimist": "~0.0.8"
}
the ~
means patch updates (most typical use)then we can do
npm publish
function vvvv(){
ddd
}