例子:
const path = require('path');
const dirName = path.dirname(__filename);
例子:
const path = require('path');
const dirName = path.dirname('file.txt'); // 错误的文件路径
例子:
const path = require('path');
const dirName = path.dirname(fileName); // 错误的变量名
例子:
const path = require('path');
const dirName = path.dirname(__filename);
console.log(dirName); // 忘记打印结果
例子:
const path = require('path');
const dirName = path.dirname(__filename); // 在浏览器端使用