最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why does Vite use dirname(fileURLToPath(import.meta.url))? - Stack Overflow

programmeradmin2浏览0评论

The vite build documentation gets the directory of vite.config.js like this:

const __dirname = dirname(fileURLToPath(import.meta.url))

Why is it being done like this? According to How do I get the path to the current script with Node.js? we can get the __dirname directory via import.meta.dirname for more recent versions of Node, so is const __dirname = dirname(fileURLToPath(import.meta.url)) just an older way of doing it?

Is it safe to switch to import.meta.dirname when working in the latest version of Node?

发布评论

评论列表(0)

  1. 暂无评论