当前位置:网站首页>Path Join() and path The difference between resolve()
Path Join() and path The difference between resolve()
2022-06-22 10:36:00 【Ah Fei】
nodejs in path.join() and path.resolve()
Basic introduction
__dirname: Returns the absolute path of the current file
introduce path modular
const path = require('path')
Use

path.join()
path.join() The main function is to splice paths
path.join Method is used to connect the path . The main purpose of this method is , Will correctly use the path separator of the current system ,Unix System is ”/“,Windows System is ”\“.
console.log(path.join('a', 'b', '..', 'c/', './d'));
// take path The pieces are connected
// Output :a/c/d
path.resolve()
path.resolve() Method is used to convert a relative path to an absolute path .
/ As the root of the absolute path , encounter / Then go back to root directory resolution
It can accept multiple parameters , Indicate the path to enter in turn , Until the last parameter is converted to an absolute path . If the absolute path cannot be obtained according to the parameters , Take the current path as the benchmark . Except for the root directory , The return value of this method has no trailing slash
path.resolve(); // The absolute path of the directory is returned by default , be equal to __dirname
path.resolve('/foo/bar', './baz')
// '/foo/bar/baz'
path.resolve('/foo/bar', '/tmp/file/')
// '/tmp/file'
The effect of execution is similar to cd operation
cd /foo/bar ==> /foo/bar
cd ./baz ==> /foo/bar
cd /tmp/file ==> /tmp/file
边栏推荐
- Encryption market plummeted, Seth triggered a new round of concern
- 喜讯丨敏捷科技入选《2022年中国数字安全百强报告》
- 普乐蛙VR台风逃生体验VR灾害自救模拟系统VR科普知识设备
- Pule frog 5D flying cinema 5D dynamic cinema experience hall equipment 7d multi person interactive cinema
- Thinkphp3.2.3 log inclusion analysis
- 【JMeter】JMeter如何模拟不同的网络速度
- LeetCode Algorithm 剑指 Offer 24. 反转链表
- Spark精简面试
- Pycharm调试卡住,出现connected
- The data intelligence infrastructure upgrade window is approaching? See Chapter 9 how Yunji dingodb breaks through data pain points
猜你喜欢

From in MySQL_ Unixtime and UNIX_ Timestamp processing database timestamp conversion - Case
![[popular science] to understand supervised learning, unsupervised learning and reinforcement learning](/img/24/d26c656135219a38fd64e4d370c9ee.png)
[popular science] to understand supervised learning, unsupervised learning and reinforcement learning

Foreign trade topic: foreign trade e-mail marketing template

Web Configuration of Visual Studio Code

Laravel 中类似 WordPress 的钩子和过滤器

Bluetooth, WiFi, ZigBee, Lora, Nb lot, call signal, network signal 4G

外贸专题:外贸邮件营销模板

Catch up with this big guy

After using Matplotlib for so long, I didn't know that the data could move

Vs2022 connecting to SQLSERVER database tutorial
随机推荐
Catch up with this big guy
HMS Core新闻行业解决方案:让技术加上人文的温度
西电AI专业排名超清北,南大蝉联全国第一 | 2022软科中国大学专业排名
Construction details of Danzhou clean animal laboratory
Pule frog VR typhoon escape experience VR disaster self rescue simulation system VR popular science knowledge equipment
大学生期末考试SQL语句
xlrd.biffh.XLRDError: Excel xlsx file; not supported 解决办法
[LineCTF2022]BB
Evaluation of scientific research award and entrepreneurship Award
Pareto's law at work: focus on results, not outputs
Use of libevent
10-2xxe vulnerability principle and case experiment demonstration
IPO Configuration Guide
Zuckerberg's latest VR prototype is coming. It is necessary to confuse virtual reality with reality
【jenkins】shell脚本调jenkins api接口
Byte 2: why is the key of the redis master node expired, but the expired data is still read from the secondary node? How to solve it?
【这款工具配合jmeter,会让你的工作效率至少提升80%,强烈推荐给大家】
What kind of experience is middle-aged unemployment
Opencv人脸识别之发送QQ邮箱
iNFTnews | 观点:市场降温或是让NFT应用走向台前的机会