javascript - NodeJS - convert relative path to absolute -


in file-system working directory here:

c:\temp\a\b\c\d

and under b\bb there's file: tmp.txt

c:\temp\a\b\bb\tmp.txt

if want go file working directory, i'll use path:

"../../bb/tmp.txt" 

in case file not exist want log full path , tell user:
"the file c:\temp\a\b\bb\tmp.txt not exist".

my question:

i need function convert relative path: "../../bb/tmp.txt" absolute: "c:\temp\a\b\bb\tmp.txt"

in code should this:

console.log("the file" + converttoabs("../../bb/tmp.txt") + " not exist") 

use path.resolve

try:

resolve = require('path').resolve resolve('../../bb/tmp.txt') 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -