2013-12-24 165 views
17

我碰到我節點應用此錯誤:ENOENT,沒有這樣的文件或目錄

ENOENT, no such file or directory '~/Desktop/MyApp/newversion/partials/navigation.jade' 

我知道這個文件是存在的,因爲當我嘗試打開使用精確複製和粘貼路徑的文件,有用。 我也知道應用程序正在使用正確的目錄,因爲它輸出錯誤。

回答

10

蒂爾德擴張是一個殼事情。寫正確的路徑名(可能/home/ yourusername /Desktop/etcetcetc),或使用
process.env.HOME + '/Desktop/blahblahblah'

+0

嗯,我認爲這是由 'app.locals.basedir = '〜/桌面/ BitBox/thenewbox' 辦理;' 我試圖 'app.set( '家',process.env。 HOME || '/ Users/Kinnard/Desktop/BitBox/thenewbox');' 但是,這並沒有工作,同樣的錯誤。 –

+0

好吧,只需將'app.locals.basedir ='〜/ Desktop/BitBox/thenewbox';'改爲絕對路徑。謝謝! –

+0

這也讓我感到:D – blong

15

我相信以前的答案是正確的回答這個問題,但我得到這個錯誤,當我嘗試安裝NPM包(見下文):

enter image description here

對我來說,修復是:npm init --yes

enter image description here

相關問題