Reputation: 3010
I'm getting this error from my Node.js application:
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.
Upvotes: 104
Views: 535718
Reputation: 113
You might have multiple npmrc configurations.
just run this:
npm config set registry "https://registry.npmjs.com/"
Upvotes: 0
Reputation: 22382
I believe the accepted answer is the correct answer to this problem but I was getting this error when I tried installing my npm package with npm install mailgun-js
(see below):
The fix for me was: npm init --yes
Upvotes: 51
Reputation: 2076
I was also plagued by this error, and after trying all the other answers, magically found the following solution:
Delete file package-lock.json and the node_modules folder, and 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 rerunning npm install
.
It worked for me!
Upvotes: 22
Reputation: 525
For me, the trouble was caused by the fact that my code folder was a subdirectory of my Dropbox folder, on Windows 10. During the build process, the Dropbox application would complain about working with more than 500,000 files.
I moved my folder out from the Dropbox directory and now it builds fine!
Upvotes: 1
Reputation: 10662
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=http://private.package.source/secret/npm-packages/
Upvotes: 0
Reputation: 179
My problem was that I didn't have a package.json file in my working directory.
Upvotes: 0
Reputation: 15
I ran into this upgrading a Phoenix app to 1.6, which does not use Node.js, so in fact it is not needed. However, elixir_buildpack.config
had a reference to phoenix_static_buildpack.config
, which defined node. Remove the reference, and the error goes away.
Upvotes: 0
Reputation: 336
Sometimes you are just not in the right directory. Check that once and try "npm start" again.
Upvotes: 0
Reputation: 31
It usually occurs due to a mismatch in the npm
version used while creating the package-lock.json
that currently exist and the one you are using now.
Removing the package-lock.json and running npm install
worked for me.
Upvotes: 1
Reputation: 895
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 a command prompt (for Windows) to open the code. I am using Visual Studio Code, so it is to type "code." after I have opened the command prompt in the exact folder where my code is in.
Upvotes: 0
Reputation: 16309
When this happened to me, it was when trying to run Karma tests in an Angular 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 the runner was looking for tests in the wrong folder. This may be a different use case from the OP, but the same error message brought me here and led me down the rabbit hole of trying the npm install
solutions to no avail.
Upvotes: 1
Reputation: 8323
__dirname
Gives you the current Node.js application's root directory.
In your case, you'd use
__dirname + '/Desktop/MyApp/newversion/partials/navigation.jade';
See this answer:
How can I get the application base path from a module in Node.js?
Upvotes: 10
Reputation: 175
For those running Laravel Mix with npm run watch
, just terminate the script and run the command again.
Upvotes: 2
Reputation: 409
npm install
. If the issue is not yet fixed, try the following one after the other.npm cache clean
, thennpm install -g npm
, then
npm install
. Finallyng serve --o
to run the project.Upvotes: 20
Reputation: 1007
I had that issue using the path module:
const path = require('path');
And also do not forget to create the uploads directory first period.
Upvotes: 4
Reputation: 43
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
Upvotes: 0
Reputation: 3657
Specifically, rm yarn.lock
and then yarn install
fixed this for me.
Upvotes: 2
Reputation: 239841
Tilde expansion is a shell thing. Write the proper pathname (probably /home/
yourusername/Desktop/etcetcetc
) or use
process.env.HOME + '/Desktop/blahblahblah'
Upvotes: 31