2015-09-25 55 views
0

嗨我使用下面的代碼來創建一個服務器進程。使用child_process.fork改變了__filename和__dirname?

child_process.fork('./src/server.js'); 

但是在服務器的過程中,__filename和__dirname分別變爲 '/' 和 '/index.js'。

// in server.js 
console.log(__dirname); // output as/
console.log(__filename); // output as /index.js 

任何想法?

回答

1

哦,我意識到使用webpack時犯了一個錯誤。我應該在配置中設置以下內容。

{ 
    node: { 
    __filename: false, 
    __dirname: false, 
}