ENOENT, no such file or directory
Solution 1
Tilde expansion is a shell thing. Write the proper pathname (probably /home/
yourusername/Desktop/etcetcetc
) or use
process.env.HOME + '/Desktop/blahblahblah'
Solution 2
I believe the previous answer is the correct answer to this problem but I was getting this error when I tried installing npm package (see below) :
The fix for me was : npm init --yes
Solution 3
- First try
npm install
,if the issue is not yet fixed try the following one after the other. -
npm cache clean
,then -
npm install -g npm
,thennpm install
,Finally -
ng serve --o
to run the project. Hope this will help....
Solution 4
I was also plagued by this error, and after trying all the other answers, magically found the following solution:
Delete package-lock.json and the node_modules folder, then run npm install
again.
If that doesn't work, try running these in order:
npm install
npm cache clean --force
npm install -g npm
npm install
(taken from @Thisuri's answer and @Mathias Falci's comment respectively)
and then re-deleting the above files and re-running npm install
.
Worked for me!
Solution 5
__dirname
Gives you the current node application's rooth directory.
In your case, you'd use
__dirname + '/Desktop/MyApp/newversion/partials/navigation.jade';
See this answer:

Kinnard Hockenhull
Updated on July 05, 2022Comments
-
Kinnard Hockenhull 6 months
I'm getting this error from my node app:
ENOENT, no such file or directory '~/Desktop/MyApp/newversion/partials/navigation.jade'
I know the file is there because when I try to open the file using the exact copied and pasted path, it works. I also know the application is using the right directory because, well, it outputs it in the error.
-
Kinnard Hockenhull almost 9 yearsHmm, I thought that was handled by
app.locals.basedir = '~/Desktop/BitBox/thenewbox';
I triedapp.set('home', process.env.HOME || '/Users/Kinnard/Desktop/BitBox/thenewbox');
But that didn't work, same error. -
Kinnard Hockenhull almost 9 yearsOk, just changing
app.locals.basedir = '~/Desktop/BitBox/thenewbox';
to the absolute path worked. Thanks! -
pnet over 4 yearsI'm having this error too. I have no path: ..node_module/rxjs. What am i doing wrong? my issue: ** ./node_modules/rxjs/_esm5/index.js Module build failed: Error: ENOENT: no such file or directory, open '..\ClientApp\node_modules\rxjs_esm5\index.js'**
-
BraveNewMath about 4 yearsYou might want to look at this answer: stackoverflow.com/questions/21637099/…
-
ruffin over 2 yearsCan you explain what this does and why it might fix the issue?
-
Prusio almost 2 yearswhat does npm install -g npm do? any doc i can find info about it?
-
Damien over 1 year@Prusio It is the command to update npm (after it has been installed).
-
Manoj 10 monthsYes this magic way of solution helped me.