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.
113 Answers
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
Tilde expansion is a shell thing. Write the proper pathname (probably /home/yourusername/Desktop/etcetcetc) or useprocess.env.HOME + '/Desktop/blahblahblah'
- First try
npm install,if the issue is not yet fixed try the following one after the other. npm cache clean,thennpm install -g npm,thennpm install,Finallyng serve --oto run the project. Hope this will help....
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!
1__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:
App base path from a module in NodeJS
I had that issue : use path module
const path = require('path');and also do not forget to create the uploads directory first period.
For those running Laravel Mix with npm run watch, just terminate the script and run the command again.
For me, it was having my code folder in Dropbox on windows 10. During the build process Dropbox would flip out over having more than 500,000 files. I moved my folder out and now it builds fine!
Specifically, rm yarn.lock and then yarn install fixed this for me.
When this happened to me, it was when trying to run karma tests in an angulare project. The tsconfig.spec.js file turned out to be incorrect. It was basically pointing to the wrong directory, and so the error was simply trying to tell me this.
For example, we had ../tsconfig.json instead of ./tsconfig.json so runner was looking for tests in the wrong folder. This may be different usecase from OP, but same error message brought me here and led me down the rabbit hole of trying the npm install solutions to no avail.
Another possibility is that you are missing an .npmrc file if you are pulling any packages that are not publicly available.
You will need to add an .npmrc file at the root directory and add the private/internal registry inside of the .npmrc file like this:
registry= Reason: I have the same issue, where a few guys work on one project and change package dependencies.
Solution: Just kill file package-lock.json and run npm i again
In my case, I was running the terminal in the wrong folder. Please make sure that you navigate to the folder containing your code (App.js and others) and then use Command prompt (for Windows) to open the code. I am using VS code so it is to type "code." after I have opened Command prompt in the exact folder where my code is in.