I am new to nodejs. Can node resolve ~ (unix home directory) example ~foo, ~bar to /home/foo, /home/bar
> path.normalize(\'~mvaidya\') \'~mvaidya\' > path.resolve(
This NodeJS library supports this feature via an async callback. It uses the etc-passswd lib to perform the expansion so is probably not portable to Windows or other non Unix/Linux platforms.
If you only want to expand the home page for the current user then this lighter weight API may be all you need. It's also synchronous so simpler to use and works on most platforms.
Examples:
expandHomeDir = require('expand-home-dir')
expandHomeDir('~')
// => /Users/azer
expandHomeDir('~/foo/bar/qux.corge')
// => /Users/azer/foo/bar/qux.corge
Another related lib is home-dir that returns a user's home directory on any platform:
https://www.npmjs.org/package/home-dir