1. 程式人生 > >node.js中的path.resolve方法使用說明

node.js中的path.resolve方法使用說明


path.resolve('/foo/bar', './baz')
 
// returns
 
'/foo/bar/baz'
 
path.resolve('/foo/bar', '/tmp/file/')
 
// returns
 
'/tmp/file'
 
path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
 
// if currently in /home/myself/node, it returns
 
'/home/myself/node/wwwroot/static_files/gif/image.gif'