path.join vs path.resolve in node.js
path.join([...paths])
- joins all the path segments using platform specific delimiter.
path.join('/foo', 'bar', 'baz/zxcv', 'abcd', '..') // '/foo/bar/baz/zxcv/abcd/...'
path.resolve([...paths])
- Resolves all the path segments into an absolute path.
- It processes from right to left, until an absolute path is created.
- If after processing all given path segments an absolute path has not yet been generated, the current working directory is used.
path.resolve('/foo/bar', '/temp/file/') // '/temp/file'
path.resolve('www', 'static/png/', '../gif/image.gif') // '/home_dir/www/static/gif/image.gif'
- (path.resolve)[https://nodejs.org/api/path.html#path_path_resolve_paths]
- (path.join)[https://nodejs.org/api/path.html#path_path_join_paths]