. Advertisement .
..3..
. Advertisement .
..4..
Hi everyone, I’m learning about javascript. While working, I try use my Node app in my project. As a result, I get the message:
ENOENT, no such file or directory '~/Desktop/MyApp/newversion/partials/navigation.jade'
What can I do about the “enoent: no such file or directory” issue? Is there a better approach?
The cause:
The file you’re looking for is in the current working directory. This is referred to as a relative path. You are not passing the whole path of a file to the open() method in the preceding code, only its name – a relative path. Therefore, the error “FileNotFoundError: [Errno 2] No such file or directory” happens because the working directory does not contain a file with that name.
Solution:
Instead of utilizing the relative route, consider using the exact or absolute path. For example,
/home/
yourusername/Desktop/etcetcetc
or you can useprocess.env.HOME + '/Desktop/blahblahblah'
Or you can do as the following steps:
1. First, let’s install
npm install
.2. Then, run
npm cache clean
.3.
npm install -g npm
,after thatnpm install
.4. Finally, use
ng serve --o
to run the project.Above suggestion is also an useful way to solve your error.
Although I think the answer to the problem is correct, I got this error when installing the npm package (see below).
For me, the solution was
npm init --yes