npm 10 things – one – two



npm 10 things – one – two

1 1


npm-10-things

Presentation on npm given at LNUG August 2013

On Github alanshaw / npm-10-things

npm 10 things

Created by Alan Shaw / @_alanshaw

zero

Backed by couchdb

http://isaacs.iriscouch.com/registry

NoSQL, JSON documents, query using JavaScript & MapReduce, access via HTTP

one

It's just a node module. Use it programmatically.

var npm = require("npm")

npm.load({}, function (er) {
  if (er) return console.error(er)

  var cmdArgs = ["async"]

  // Install the async module ...or do whatever - view, search, update, test 
  npm.commands.install(cmdArgs, function (er) {
    if (er) return console.error(er)

    console.log("async installed")
  })
})

two

Configure all the things!

Configure all the things?

  • Command line flags
    • --foo=bar
  • Environment vars
    • NPM_CONFIG_FOO=bar
  • npmrc files
    • ~/.npmrc
    • $PREFIX/npmrc
    • /path/to/npm/npmrc

Configure ALL the things?

  • Cache location
  • Registry URL
  • YES

three

Run your own npm ?

Get you an enterprise one from nodejitsu

four

npm link [module]

Create a globally installed symlink in   node_modules/[module]   to   /path/to/[module]

First:

cd /path/to/[module]
npm link

Then:

npm link [module]
# node_modules/[module] now symlinked to /path/to/[module]

five

The npm cache folder ~/.npm

cache-max

The maximum time (in seconds) to keep items in the registry cache before re-checking against the registry.

Default is infinity unless you...

npm cache clean

six

npm search [term]

...caches text in

~/.npm/-/all/.cache.json

...and searches through it with regular expressions

It's 14MB

seven

npm tag <name>@<version> [<tag>]

Identify a version by name.

"latest" is an auto tag, that gets updated to point to the latest version

eight

Depend on a version, a tag, an archive, or a git repo

{
  "dependencies": {
    "foo": "~1.2.3",
    "bar": "latest",
    "baz": "http://asdf.com/archive.tar.gz",
    "boz": "git://github.com/user/project.git#commit"
  }
}

nine

npm version 1.2.3

It'll open up your package.json file, change the version to 1.2.3, git add it, git commit it, and git tag v1.2.3 it.

ERMAHGERD.

end

github.com/alanshaw/npm-10-things @_alanshaw