- 当前路径
console.log(process.cwd())
- 当前路径
- 2.执行函数
process.nextTick(()=>{
console.log("NextTick");
});//执行最早,插入当前队列的最后
setTimeout(() => {
console.log('timeout');
}, 0);//执行时间介于前后两者
setImmediate(()=>{
console.log('setImmediate');
});//较晚
- 3.调试
运行文件,并在开始处暂停
node --inspect-brk yourfile.js
打开Chrome
输入网址chrome://inspect/
,选中target,然后inspect即可。
PATH模块
-
normalize
将路径规范化,支持../
层级访问
const {normalize}=require('path');
console.log(normalize('C:\\users\\\\a.text'));
-
join
自动拼接路径
const {join}=require('path');
console.log(join('C:\\','a.txt'));
-
resolve
将相对路径解析为全局路径
const {resolve}=require('path');
console.log(resolve('./'));
- basename,dirname,extname
const {basename,dirname,extname}=require('path');
const filepath='C:\\project\\a.txt';
console.log(basename(filepath));
console.log(dirname(filepath));
console.log(extname(filepath));
结果
a.txt
C:\project
.txt