问题描述:

In some Express example, I see there are two ways to define directory to store view file.

First is:

app.set('views', './views');

Second is:

app.set('views', __dirname + '/views');

My question is: Are there any differences for above two methods ? I have run and see no different effect.

Thanks :)

网友答案:

__dirname repersent the current directory in which your app.js file is present. Also . also repersent current directory in which your app.js present. Difference is that using two dots e.g ../anyFolderName you will move one directory upwith respect to current directory. __dirname isn't actually a global but rather local to each module.Hope now difference will be clear to you

相关阅读:
Top