2016-11-22 54 views

回答

0

萬一有人正在尋找的答案:

require.main.require指向根文件,在這種情況下,茉莉(不是你的app.js等)。您需要創建一個茉莉花幫手,它覆蓋您的require.main.require函數,如下所示:

const path = require('path'); 

require.main.require = function(pathName) { 
    //path to root app: 
    const newPath = path.join(__dirname, '../', pathName); 

    return require(newPath); 
}