NodeJS - convert relative path to absolute

前端 未结 2 1062
野性不改
野性不改 2020-12-14 05:44

In my File-system my working directory is here:

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

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

C:\\tem

2条回答
  •  执笔经年
    2020-12-14 05:49

    Use path.resolve

    try:

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

提交回复
热议问题