Notes
Notes copied to clipboard
path.resolve最简单的解释
先介绍下的3个路径的含义.
/
根目录
./
当前目录
../
上级目录
path.resolve可以理解为cd命令., 那么官网的例子就好理解了:
path.resolve('/foo/bar', './baz');
// 返回: '/foo/bar/baz'
path.resolve('/foo/bar', '/tmp/file/');
// 返回: '/tmp/file'
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif');
// 如果当前工作目录是 /home/myself/node,
// 则返回 '/home/myself/node/wwwroot/static_files/gif/image.gif'