showing results for - "how to use node js path"
Leni
31 Feb 2020
1The Node.js path module handle and transform files paths. 
2
3Use below syntaxt to to import module :
4
5var path =  require ("path")  
6
7Node.js Path Methods and examaple 
8
91. normalize(p)
10	It is used to normalize a string path, taking care of '..' and '.' parts.
11    
12Sytntax :     
13path.normalize(p)
14
15Out put :
16// Normalization  
17console.log('normalization : ' + path.normalize('/sssit/user//node/newfolder/tab/..')); 
18
192. join([path1][, path2][, ...])
20	 path2][, ...])	It is used to join all arguments together and normalize the resulting path.
21
22Sytntax : 
23path.join([path1][, path2][, ...])
24
25// Join  
26console.log('joint path : ' + path.join('/sssit', 'user', 'node/newfolder', 'tab', '..'));  
27
283. resolve([from ...], to)
29	It is used to resolve an absolute path.
30
31Syntax :
32path.resolve([from ...], to)
33
34// Resolve  
35console.log('resolve : ' + path.resolve('path_example.js'));  
36
374. extname(p)
38
39Styntax : 
40path.extname(p)
41
42// Extension   
43console.log('ext name: ' + path.extname('path_example.js')); 
similar questions
queries leading to this page
how to use node js path