Allow npm to install to a directory that doesn't yet exist

If path is specified but does not exist, create it.
Fail if path is specified but is not a directory
Merge pull request #6612 from willthames/npm_fix_nonexistent_path

Allow npm to install to a directory that doesn't yet exist