Method description:
Parses the character at the parameter to position into an absolute path.
grammar:
The code copy is as follows:
path.resolve([from ...], to)
Since this method belongs to the path module, you need to introduce the path module before use (var path= require("path") )
Receive parameters:
from source path
to string that will be parsed to the absolute path
example:
The code copy is as follows:
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'
Another way is to use it as a sequence of cd command shell.
The code copy is as follows:
path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile')
Similar to:
The code copy is as follows:
cd foo/bar
cd /tmp/file/
cd ..
cd a/../subfile
pwd