【图文演示】__dirname和process.cwd()的区别

// __dirname和process.cwd().js

console.log('dirname: ', __dirname);
console.log('process.cwd(): ', process.cwd());

【图文演示】__dirname和process.cwd()的区别

疑问1:__dirnameprocess.cwd()的区别
答:__dirname是指被执行的js文件的所在目录,而process.cwd()则指的是执行node命令的所在目录

评论
:broken_heart: :confounded: :flushed: :frowning: :grinning: :heart: :kissing_heart: :mask: :pensive: :rage: :relaxed: :scream: :smile: :smirk: :sob: :stuck_out_tongue_closed_eyes: :stuck_out_tongue_winking_eye: :wink: