Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はそこにいますc:\nodejs\www\project\bin\server.js
c:\nodejs\www\project\bin\server.js
私の見解はc:\nodejs\www\project\views
c:\nodejs\www\project\views
それから私server.jsは持っています:
server.js
.set('views', __dirname + '/views')
しかし、生成されたパスは次のとおりです。c:\nodejs\www\project\bin\views
c:\nodejs\www\project\bin\views
binフォルダの親を取得するには?
bin
ExpressとEjsを使用しています。
よろしく
これを行うには2つの方法があります。私は考えることができます:
.set('views',__dirname + '../views');
または
path モジュールから path.join を使用できます
var path = require("path"), .set(path.join(__dirname, '..', 'views'));
これらは、ファイルを見つけるためにディレクトリ構造の後ろの1つの親を取得します。