Permalink
Browse files

Updates for the recording and cleanup

  • Loading branch information...
1 parent 9db5afd commit 09d0a46440a347317323153199c78451c5cc7463 @croach committed Apr 14, 2012
Showing with 276 additions and 164 deletions.
  1. +276 −164 02.md
View
440 02.md
@@ -2,208 +2,320 @@
## Introduction
-Hi guys. Well it's been a little while since our last session, and I do apologize for such a long hiatus, but I'm back
-now and I'm looking forward to continuing this series on node development.
-
-Today's session will be a little different from the first two. We've got a bit of a taste for node already in the
-previous sessions, and now I want to go off on a bit of a tangent and dive into some of the infrastructure that's grown
-up around node to help make developing in it much easier. Today will be all about learning a couple of the most
-important tools for developing Node applications that will, hopefully, make you much more effective and will also aid
-you in the completion of this series.
-
-The tools that we'll be covering today are [nvm][nvm] and [npm][npm]. The Node Version Manager, or nvm as it is usally
-refered to, as the name suggests, is a tool for managing multiple versions of Node. Node is still in it's pre-1.0 phase
-and, as such, can be a bit volatile. As a developer it pays to have a way of locking a project into a specific version
-of Node once you've started developing with it and nvm is going to be our way of doing that. The npm project, which
-officially does not stand for anything, is a package manager. Like gems for Ruby or pip for Python, it allows us to
-install and manage any number of third party libraries without all the worries of finding and installing dependencies
-and so on and so forth. Finally, as a bonus, we'll put npm to use by installing another third party program from the
-maker of npm that should help make developing Node apps much less painful.
-
-So, apologies made and summary out of the way, let's get right down to business.
+Hi guys. Well it's been a little while since our last session, and I
+do apologize for such a long hiatus, but I'm back now and I'm looking
+forward to continuing this series on node development.
+
+Today's session will be a little different from the first two. We've
+got a bit of a taste for node already in the previous sessions, and
+now I want to go off on a bit of a tangent and dive into some of the
+infrastructure that's grown up around node to help make developing in
+it much easier. Today will be all about learning a couple of the most
+important tools for developing Node applications that will, hopefully,
+make you much more effective and will also aid you in the completion
+of this series.
+
+The tools that we'll be covering today are [nvm][nvm] and [npm][npm].
+
+First on our list is the Node Version Manager, or nvm as it is usally
+refered to. As its name would suggest, it's a tool for managing
+multiple versions of Node. Node is still in it's pre-1.0 phase and, as
+such, can be a bit volatile. As a developer it pays to have a way of
+locking a project into a specific version of Node once you've started
+developing with it and nvm is going to be our tool for doing just
+that.
+
+Next on our list is npm, which while its website states that npm
+officially doesn't stand for anything, it is in fact the package
+manager for node, so I'll let you draw your own conclusions on what
+the name really means. Like gems for Ruby or pip for Python, it allows
+us to install and manage any number of third party libraries without
+all the worries of finding and installing dependencies and so on and
+so forth.
+
+Finally, as a bonus, we'll put npm to use by installing another third
+party program from the maker of npm that should help make developing
+Node apps much less painful.
+
+So, apologies made and summary out of the way, let's get right down to
+business.
## Node Version Manager (nvm)
-Considering that it's been such a long break since our last session, and, in the interim, Node has advanced from
-release 0.4.5 to 0.6.13, I think a good topic to start off with would be the Node Version Manager. As the name
-suggests, nvm will allow you to install and switch between several different versions of Node. Coupled with npm, which
-we'll be discussing next, you can create virtual environments around specific versions of node and any third party
-libraries that you'll be using in your projects. If you're familiar at all with virtualenv for Python, you'll have some
-idea of what the combination of these two pieces of software has to offer.
+We'll start off by taking a look at nvm. In the interim since our last
+session, node has advanced from release 0.4.5 to 0.6.15. Considering
+the speed at which node is advancing, it's vital that we have a tool
+that allows us to create sandboxed development envrionments that are
+protected from all the volatility in the node world, and nvm is that
+tool. Couple it with npm, which we'll be discussing next, and you can
+create virtual environments around both specific versions of node and
+any third party libraries that you'll be using in your projects. If
+you're familiar at all with virtualenv for Python, you'll have some
+idea of what the combination of these two pieces of software has to
+offer.
### Installation
-The installation of nvm is quite simple, just go to its github page in your browser (you can do so by simply googling
-nvm and, most likely, it will be one of the first few results---if not the first). The installation is quite simple,
-it's basically a matter of storing the nvm directory somewhere in your filesystem and then sourcing the main shell
-script whenever you start a new shell. So, if you have git installed on your computer, you can copy this line here
-[copy the install line from the website] and run it at the command line.
+The installation of nvm is quite simple, just go to its github page in
+your browser (you can do so by simply googling nvm and, most likely,
+it will be one of the first few results---if not the first). The
+installation is quite simple, it's basically a matter of storing the
+nvm directory somewhere in your filesystem and then sourcing the main
+shell script whenever you start a new shell. So, if you have git
+installed on your computer, you can copy this line here
+[copy the install line from the website] and run it at the command
+line.
git clone git://github.com/creationix/nvm.git ~/nvm
-What this will do is checkout the nvm repository into a hidden directory named .nvm in your home directory. If you
-don't have git installed, one option would be to install it (honestly git is a great piece of software to have), but
-another option that's a bit faster is just to scroll back up a bit and click on the Downloads link here and then choose
-whether you want to download the repository as a zip file or a tarball. Once you've got that download, you'll need to
-unzip or untar it and then change its name and location to .nvm in your home directory.
-
-Next, we'll need to add little bit of code to our shell's config file, such as your .bashrc file, to make the
-environment aware of nvm. Let's go ahead and open that up now. So, here I'm going to pull up my .bashrc file---you'll
-need to place the following somewhere within this file:
+What this will do is checkout the nvm repository into a hidden
+directory named .nvm in your home directory. If you don't have git
+installed, one option would be to install it (honestly git is a great
+piece of software to have), but another option that's a bit faster is
+just to scroll back up a bit and click on the Downloads link here and
+then choose whether you want to download the repository as a zip file
+or a tarball. Once you've got that download, you'll need to unzip or
+untar it and then change its name and location to .nvm in your home
+directory.
+
+Next, we'll need to add little bit of code to our shell's config file,
+such as your .bashrc file, to make the environment aware of nvm. Let's
+go ahead and open that up now. So, here I'm going to pull up my
+.bashrc file---you'll need to place the following somewhere within
+this file:
export NVM_HOME="$HOME/.nvm"
if [[ -f "$NVM_HOME/nvm.sh" ]]; then
source "$NVM_HOME/nvm.sh"
fi
-All this bit of code here does is, whenever a new shell session is started, it will check for the existence of the
-`nvm.sh` file within the `.nvm` directory that you just created. If it exists, it will run the file within the current
-shell creating several new shell functions for you to use. Now, you don't actually need to surround the `source`
-command with the check for the file's existence since we know it's there, but I like to have it there to keep the shell
-from screaming at me whenever I remove or move my .nvm directory for whatever reason. One more thing to notice, is that
-you can actually name your nvm directory whatever you want and keep it wherever you like. Calling it .nvm and placing
-it in your home directory is the default, but if you prefer to put it somewhere else, all you have to do is just change
-the `NVM_HOME` variable in the bit of code above to reflect your preferences. So, feel free to move the nvm folder
-around to somewhere else if having a hidden directory in your home directory is not to your liking.
-
-Ok, now that we've got nvm installed, we just need to source our startup file to get nvm to be recognized in the
-current shell. To make sure everything worked properly, call `nvm` now and hopefully what you'll see is the help output
-for the command.
-
-If you just saw some help information fly across your screen, you're all setup and ready to manage multiple versions of
-node.
+All this bit of code here does is, whenever a new shell session is
+started, it will check for the existence of the `nvm.sh` file within
+the `.nvm` directory that you just created. If it exists, it will run
+the file within the current shell creating several new shell functions
+for you to use. Now, you don't actually need to surround the `source`
+command with the check for the file's existence since we know it's
+there, but I like to have it there to keep the shell from screaming at
+me whenever I remove or move my .nvm directory for whatever
+reason. One more thing to notice, is that you can actually name your
+nvm directory whatever you want and keep it wherever you like. Calling
+it .nvm and placing it in your home directory is the default, but if
+you prefer to put it somewhere else, all you have to do is just change
+the `NVM_HOME` variable in the bit of code above to reflect your
+preferences. So, feel free to move the nvm folder around to somewhere
+else if having a hidden directory in your home directory is not to
+your liking.
+
+Ok, now that we've got nvm installed, we just need to source our
+startup file to get nvm to be recognized in the current shell. To make
+sure everything worked properly, call `nvm` now and hopefully what
+you'll see is the help output for the command.
+
+If you just saw some help information fly across your screen, you're
+all setup and ready to manage multiple versions of node.
### Exploring nvm
-Now that you have nvm installed, let's play around with it a bit and see what all it has to offer and then get the
-lastest version of node installed on our system.
-
-There are a few important commands that you'll probably use quite often. The first of these is the `ls` command. Go
-ahead and type `nvm ls` at the command line and take a look at what gets printed out. Not much huh? Just an N/A (or a
-dot depending on your shell) and a second line that says `current:`. The reason your not seeing much here is that you
-haven't installed node on your system yet. Once you've got at least one node installed, the `ls` command becomes much
-more useful by listing all of the currently installed versions of node available for you to choose from as well as the
-current version in use and any aliases that you've created. Well I can't think of a better segue than that to start
-installing a copy of node. So, let's do that now.
-
-To install a version of node you invoke the `nvm install` command with the version number of the Node you want to
-install. For us that will be version 0.6.13, but an important thing to remember here is that the version number must be
-prefaced with a 'v' or else the install will not work. So, type the command `nvm install v0.6.13` at your command line
-now and you should see the download and installation begin. We want at least one more version of node installed to give
-us something to play around with, so once the current install is done, go ahead and install the version of node that we
-originally started using when we first started this series, v0.4.5. This will all take a little while so, Im just going
-to skip ahead to the end, so you may want to pause this screencast now until your installation is complete.
-
-Now that we've got a couple of versions of node installed on our system, let's take another look at the output of `nvm
-ls`. Notice that it's now listing our installed versions of Node and the one that we installed last is the current
-version that we are using. You can confirm this by typing `node -v` and making sure that the version that pops up
-matches the version listed by `current:` in the `ls` output. To switch to another version of node, type `nvm use`
-followed by the version number. Go ahead and do that now, switch over to the latest version of node. Now if you do an
-`nvm ls` you should see v0.6.13 listed beside `current:` and doing a `node -v` from the command line should display
-v0.6.13 as well. One thing though, try opening up a new shell and typing in `node -v` and see what happens. Hmm,
-doesn't exist huh? Doing an `nvm ls` shows us that we have two versions installed but neither is currently being
-used. You could go ahead and do a `nvm use` now, but do you really want to do that every time? Most of the time, you'll
-want the latest version of node to be the default right? Well, nvm let's us specify this behavior by declaring an
-alias. Aliases are just human readable names for specific versions. So, for example, if you like living on the cutting
-edge and you want to install the latest development version of node, you could always keep everything clear by marking
-the current version as 'stable' and the bleeding edge version as 'dev', then you can do things like `nvm use dev` or
-`nvm use stable` to switch between versions. Another nice thing about aliases is that they allow us to specify a
-default version of node. Go ahead and type `nvm alias default v0.6.13` and then run `nvm ls` again. Notice something
-new at the bottom of the output? The `ls` command lists all of our aliases at the bottom of the output. You could also
-run `nvm alias` to see only the list of available aliases as well. Now try opening up a new shell and type `node
--v`. This time you should the version number of our default node version print out to the screen. That should be enough
-to get you started with nvm. The app is fairly simple to understand and you should be able to pick up the rest by just
-looking at the help output from `nvm help`. Now I want to move onto the more interesting stuff and play around with npm
-a bit. So let's get that installed and see what all it can do for us.
-
-## Node's Package Manager (NPM)
-If you thought the install for nvm was easy, wait til you see the install for npm...
-
-Did you get all that? No, don't worry, I didn't accidentally edit out the npm install or anything it's just that npm
-comes already installed with all of the latest version of node. Anything after the 0.4 series should already come with
-npm installed and I believe, correct me in the comments if I'm wrong, all versions from v0.4.3 and up have npm already
-installed. So, essentially your done. However, there is one piece missing to the default install of npm... the docs!
-
-npm loves Unix and it shows in its documentation. All of the docs for npm are man pages and even the website docs are
-just an HTML version of the man page documentation, so it stands to reason that you'd probably want to have this very
-valuable bit of information on your local system. However, if you do a `man npm` you'll get back something to the tune
-"No manual entry for npm". So, how do we get the docs installed? Well the easiest way that I've found is simply to
-upgrade our version of npm. To do so we'll use npm, so just type `npm update -g npm` at the command line. Once the
-update is finished, you should be able to type `man npm` and get the main man page for the npm program. Now typing `npm
-help <command>` will also bring up the man page for each of the commands that npm supports.
+Now that you have nvm installed, let's play around with it a bit and
+see what all it has to offer and then get the lastest version of node
+installed on our system.
+
+There are a few important commands that you'll probably use quite
+often. The first of these is the `ls` command. Go ahead and type `nvm
+ls` at the command line and take a look at what gets printed out. Not
+much huh? Just an N/A (or a dot depending on your shell) and a second
+line that says `current:`. The reason your not seeing much here is
+that you haven't installed node on your system yet. Once you've got at
+least one node installed, the `ls` command becomes much more useful by
+listing all of the currently installed versions of node available for
+you to choose from as well as the current version in use and any
+aliases that you've created. Well I can't think of a better segue than
+that to start installing a copy of node. So, let's do that now.
+
+To install a version of node you invoke the `nvm install` command with
+the version number of the Node you want to install. For us that will
+be version 0.6.13, but an important thing to remember here is that the
+version number must be prefaced with a 'v' or else the install will
+not work. So, type the command `nvm install v0.6.13` at your command
+line now and you should see the download and installation begin. We
+want at least one more version of node installed to give us something
+to play around with, so once the current install is done, go ahead and
+install the version of node that we originally started using when we
+first started this series, v0.4.5. This will all take a little while
+so, Im just going to skip ahead to the end, so you may want to pause
+this screencast now until your installation is complete.
+
+Now that we've got a couple of versions of node installed on our
+system, let's take another look at the output of `nvm ls`. Notice that
+it's now listing our installed versions of Node and the one that we
+installed last is the current version that we are using. You can
+confirm this by typing `node -v` and making sure that the version that
+pops up matches the version listed by `current:` in the `ls`
+output. To switch to another version of node, type `nvm use` followed
+by the version number. Go ahead and do that now, switch over to the
+latest version of node. Now if you do an `nvm ls` you should see
+v0.6.13 listed beside `current:` and doing a `node -v` from the
+command line should display v0.6.13 as well. One thing though, try
+opening up a new shell and typing in `node -v` and see what
+happens. Hmm, doesn't exist huh? Doing an `nvm ls` shows us that we
+have two versions installed but neither is currently being used. You
+could go ahead and do a `nvm use` now, but do you really want to do
+that every time? Most of the time, you'll want the latest version of
+node to be the default right? Well, nvm let's us specify this behavior
+by declaring an alias. Aliases are just human readable names for
+specific versions. So, for example, if you like living on the cutting
+edge and you want to install the latest development version of node,
+you could always keep everything clear by marking the current version
+as 'stable' and the bleeding edge version as 'dev', then you can do
+things like `nvm use dev` or `nvm use stable` to switch between
+versions. Another nice thing about aliases is that they allow us to
+specify a default version of node. Go ahead and type `nvm alias
+default v0.6.13` and then run `nvm ls` again. Notice something new at
+the bottom of the output? The `ls` command lists all of our aliases at
+the bottom of the output. You could also run `nvm alias` to see only
+the list of available aliases as well. Now try opening up a new shell
+and type `node -v`. This time you should the version number of our
+default node version print out to the screen. That should be enough to
+get you started with nvm. The app is fairly simple to understand and
+you should be able to pick up the rest by just looking at the help
+output from `nvm help`. Now I want to move onto the more interesting
+stuff and play around with npm a bit. So let's get that installed and
+see what all it can do for us.
+
+## Node's Package Manager (NPM) If you thought the install for nvm was
+easy, wait til you see the install for npm...
+
+Did you get all that? No, don't worry, I didn't accidentally edit out
+the npm install or anything it's just that npm comes already installed
+with all of the latest version of node. Anything after the 0.4 series
+should already come with npm installed and I believe, correct me in
+the comments if I'm wrong, all versions from v0.4.3 and up have npm
+already installed. So, essentially your done. However, there is one
+piece missing to the default install of npm... the docs!
+
+npm loves Unix and it shows in its documentation. All of the docs for
+npm are man pages and even the website docs are just an HTML version
+of the man page documentation, so it stands to reason that you'd
+probably want to have this very valuable bit of information on your
+local system. However, if you do a `man npm` you'll get back something
+to the tune "No manual entry for npm". So, how do we get the docs
+installed? Well the easiest way that I've found is simply to upgrade
+our version of npm. To do so we'll use npm, so just type `npm update
+-g npm` at the command line. Once the update is finished, you should
+be able to type `man npm` and get the main man page for the npm
+program. Now typing `npm help <command>` will also bring up the man
+page for each of the commands that npm supports.
### Configuration and documentation
-Now that we've got the latest version of npm installed on our system, let's play around a bit and see what all it has
-to offer. npm is extremely configurable and has tons of cool features that you can play with. Let's get started by
-changing the default format for the documentation. We just saw how you can view the documenation for npm via man pages,
-but what if you don't happen to be a fan of reading docs from the command line? Perhaps you'd like your documentation
-to be in the form of a web page? If so, there's a configuration setting just for you. Let's start by taking a look at
-what the current setting is. Type `npm config get viewer` to see what the current medium for documenation viewing
-is. You should see 'man' get printed to the screen. Let's change that now to be the browser by typing `npm config set
-viewer browser` and confirm the change by typing `npm config get viewer` again. If 'browser' is now printed out, you've
-successfully updated the viewer configuration setting and you're ready to start viewing the npm documentation in
-beautiful HTML. Go ahead and give it a try now by typing `npm help npm` into the command line. Hopefully, your default
-browser opened up if you're running OS X, otherwise, I believe you need to Chrome installed for this feature to
-work. To revert the configuration setting back to it's default, just delete it with `npm config delete viewer`. A quick
-check with `npm get config viewer` proves that the configuration setting has been reverted and running `npm help npm`
-further proves it by opening the documentation in the terminal. On a final note, if you want to keep the default
-settings, but you still want to view the docs in the browser from time to time, npm let's you do so by setting a
-configuration key via a command line option. Any configuration setting can be set via the `--key value` command line
-option. Let's try it real quick by opening up our main npm documentation in the browser again by typing `npm --viewer
-browser help npm`. The main reason that I'm running through all the different ways to view the docs is that npm is
-extremely featurful and very powerful and it's worth it to get lost in the docs for a few hours just to get an idea of
-what all it has to offer. So after we finish up with this tutorial, you should do yourself a favor and pop open the
-main help page and just read through and try out stuff, you won't regret it.
+Now that we've got the latest version of npm installed on our system,
+let's play around a bit and see what all it has to offer. npm is
+extremely configurable and has tons of cool features that you can play
+with. Let's get started by changing the default format for the
+documentation. We just saw how you can view the documenation for npm
+via man pages, but what if you don't happen to be a fan of reading
+docs from the command line? Perhaps you'd like your documentation to
+be in the form of a web page? If so, there's a configuration setting
+just for you. Let's start by taking a look at what the current setting
+is. Type `npm config get viewer` to see what the current medium for
+documenation viewing is. You should see 'man' get printed to the
+screen. Let's change that now to be the browser by typing `npm config
+set viewer browser` and confirm the change by typing `npm config get
+viewer` again. If 'browser' is now printed out, you've successfully
+updated the viewer configuration setting and you're ready to start
+viewing the npm documentation in beautiful HTML. Go ahead and give it
+a try now by typing `npm help npm` into the command line. Hopefully,
+your default browser opened up if you're running OS X, otherwise, I
+believe you need to Chrome installed for this feature to work. To
+revert the configuration setting back to it's default, just delete it
+with `npm config delete viewer`. A quick check with `npm get config
+viewer` proves that the configuration setting has been reverted and
+running `npm help npm` further proves it by opening the documentation
+in the terminal. On a final note, if you want to keep the default
+settings, but you still want to view the docs in the browser from time
+to time, npm let's you do so by setting a configuration key via a
+command line option. Any configuration setting can be set via the
+`--key value` command line option. Let's try it real quick by opening
+up our main npm documentation in the browser again by typing `npm
+--viewer browser help npm`. The main reason that I'm running through
+all the different ways to view the docs is that npm is extremely
+featurful and very powerful and it's worth it to get lost in the docs
+for a few hours just to get an idea of what all it has to offer. So
+after we finish up with this tutorial, you should do yourself a favor
+and pop open the main help page and just read through and try out
+stuff, you won't regret it.
### Tab completion
-In the meantime, we still have a few other features to cover before we finish up, so let's move on to the next one, tab
-completion. If you type `npm completion` into the command line, you'll get back a print out of the shell script that
-sets everything up. Type `npm help completion` to get some instructions on how to install it. The second line in the
-Description section tells us what to do. Specifically, we just need to copy the Synopsis line into our startup file for
-whatever shell we run. Let's go ahead and set that up now by just copying this line and exiting help, and then opening
-up our `.bashrc` file and pasting this right underneath the lines we added earlier for nvm. I'm going to go ahead and
-add another if clause around this command as well just to make sure that I have npm installed before it trys to run
+In the meantime, we still have a few other features to cover before we
+finish up, so let's move on to the next one, tab completion. If you
+type `npm completion` into the command line, you'll get back a print
+out of the shell script that sets everything up. Type `npm help
+completion` to get some instructions on how to install it. The second
+line in the Description section tells us what to do. Specifically, we
+just need to copy the Synopsis line into our startup file for whatever
+shell we run. Let's go ahead and set that up now by just copying this
+line and exiting help, and then opening up our `.bashrc` file and
+pasting this right underneath the lines we added earlier for nvm. I'm
+going to go ahead and add another if clause around this command as
+well just to make sure that I have npm installed before it trys to run
it. Let me add that now:
if npm -v >/dev/null 2>&1; then
. <(npm completion)
fi
-Now if you save that and open a new shell, hopefully everything executes properly and you don't see any error
-statements. If that's true, then try out the tab completion by typing `npm comp-TAB` and the rest should be filled in
-for you. Now this worked just fine for me in zsh, but for some reason, I had troubles with this setup in bash. So, if
-you're running bash and when you open a new shell you see several errors from npm starting with something like `Error:
-write EPIPE`, a workaround I've found is to simply replace the Synopsis line in the `.bashrc` file with the full text
-from the `npm completion` command. So, I'll go ahead and pop back out to my command line and run `npm completion` and
-copy that and go back to my `.bashrc` file and paste it within the `if` statement I added earlier. Now, if you open
+Now if you save that and open a new shell, hopefully everything
+executes properly and you don't see any error statements. If that's
+true, then try out the tab completion by typing `npm comp-TAB` and the
+rest should be filled in for you. Now this worked just fine for me in
+zsh, but for some reason, I had troubles with this setup in bash. So,
+if you're running bash and when you open a new shell you see several
+errors from npm starting with something like `Error: write EPIPE`, a
+workaround I've found is to simply replace the Synopsis line in the
+`.bashrc` file with the full text from the `npm completion`
+command. So, I'll go ahead and pop back out to my command line and run
+`npm completion` and copy that and go back to my `.bashrc` file and
+paste it within the `if` statement I added earlier. Now, if you open
another shell, everything should be working correctly.
### Search and info
-So, you've read over the docs a bit, set up tab completion, and you're ready to start installing some packages, but how
-do find them? Well npm offers a mechanism for doing that as well. Let's say, for example, that you're writing a command
-line script in node and you want to add a simple UI that uses the ncurses library. Let's do a search for that now and
-see if there's any library that adds that functionality to node. Go ahead and type `npm search ncurses` at the command
-line and you should get a list with at least one result in it for the ncurses library. Now before we decide whether or
-not to use that library (although in this case we don't have a lot of alternatives) let's dig a little deeper into the
-library using the view (or info) command. let's start by looking at what dependencies it has. Type `npm view ncurses
-dependencies` into the command line and you should see an empty object returned. So, the library has no dependency on
-any other node libraries. We can see the current version by typing `npm view ncurses version`. Maybe we also want to
-see what the library is licensed under to make sure that we can use it our project. To do so type `npm view ncurses
-licenses`. We can see that it's licensed under the MIT license which is pretty liberal and should be good for just
-about any project. Finally, try typing `npm view ncurses`. This returns a JSON object with all of the info on the
-ncurses library. All of this info is available individually by calling `npm view library attribute` where the attribute
-can be a several levels deep and accessible via a dotted attribute string. For example, let's grab the URL for the
-repository which we can see is under a separate repository object. Just type `npm view ncurses repository.url` and
-remember to use the tab completion on everything except the library name as that can be too slow.
+So, you've read over the docs a bit, set up tab completion, and you're
+ready to start installing some packages, but how do find them? Well
+npm offers a mechanism for doing that as well. Let's say, for example,
+that you're writing a command line script in node and you want to add
+a simple UI that uses the ncurses library. Let's do a search for that
+now and see if there's any library that adds that functionality to
+node. Go ahead and type `npm search ncurses` at the command line and
+you should get a list with at least one result in it for the ncurses
+library. Now before we decide whether or not to use that library
+(although in this case we don't have a lot of alternatives) let's dig
+a little deeper into the library using the view (or info)
+command. let's start by looking at what dependencies it has. Type `npm
+view ncurses dependencies` into the command line and you should see an
+empty object returned. So, the library has no dependency on any other
+node libraries. We can see the current version by typing `npm view
+ncurses version`. Maybe we also want to see what the library is
+licensed under to make sure that we can use it our project. To do so
+type `npm view ncurses licenses`. We can see that it's licensed under
+the MIT license which is pretty liberal and should be good for just
+about any project. Finally, try typing `npm view ncurses`. This
+returns a JSON object with all of the info on the ncurses library. All
+of this info is available individually by calling `npm view library
+attribute` where the attribute can be a several levels deep and
+accessible via a dotted attribute string. For example, let's grab the
+URL for the repository which we can see is under a separate repository
+object. Just type `npm view ncurses repository.url` and remember to
+use the tab completion on everything except the library name as that
+can be too slow.
### Installing packages (local vs global)
-Alright we've covered quite a bit of ground with npm, but so far we haven't installed a single library. Well get ready
-to that now, but first, we need to discuss installing locally vs globally.
+Alright we've covered quite a bit of ground with npm, but so far we
+haven't installed a single library. Well get ready to that now, but
+first, we need to discuss installing locally vs globally.
# Checks that the child directory is a subdirectory of the parent
is_subdirectory() {

0 comments on commit 09d0a46

Please sign in to comment.