I've installed Node.js for Windows and I'm trying to install a package via npm. The command prompt is in the directory of the project (C:\Users\username\Desktop\NodeTest), which contains a single helloworld.js file. Upon typing 'npm install express', I receive the following error:
ENOENT: no such file or direcotry, open 'C:\Users\username\package.json
I'm attempting this from a clean install and cmd is running as admin.
Any ideas?
To resolve the ENOENT warning message, you need to add a package. json file in the directory where you run the npm install command. And then run your npm install command again. This time, the warning message should not appear.
The only way to solve it was to close VSCode, remove node_modules from examples/simple and run npm install directly from the terminal/bash (inside examples/simple ). The problem, in my case, was that VSCode kept cached the package-lock. json from the root directory and it caused conflicts.
I was facing the same issue. I firstly delete my node_modules
and delete the cache by following command:
rm -rf node_modules && npm cache clean --force
then I delete the package-lock.json
file from my project and then hit npm install
in command prompt and it works.
As already pointed out by Subburaj this is because you are missing a package.json
.
Just run npm init
to initialize that file for you; afterwards it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With