NodeJS - convert relative path to absolute

前端 未结 2 1063
野性不改
野性不改 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')
    
    0 讨论(0)
  • 2020-12-14 06:14

    You could also use __dirname and __filename for absolute path.

    0 讨论(0)
提交回复
热议问题