__dirname当前文件下的目录(不包括文件名)
__filename当前文件下的目录(包括文件名)
const path = require('path');
console.log(__dirname); //C:\Users\Administrator\Desktop\test
console.log(__filename); //C:\Users\Administrator\Desktop\test\test.js
console.log(path.extname(__filename)); //.js
console.log(path.basename(__filename)); //test.js
console.log(path.dirname(__filename)); //C:\Users\Administrator\Desktop\test
console.log(path.parse(__filename));
//{
// root: 'C:\\',
// dir: 'C:\\Users\\Administrator\\Desktop\\test',
// base: 'test.js',
// ext: '.js',
// name: 'test'
//}
path,join(__dirname,'xxx')
//拼接操作,一个逗号表示一层路径