Home > Net >  Trying to install npm but getting errors
Trying to install npm but getting errors

Time:06-03

What am I doing wrong?

C:\WINDOWS\system32>npm install
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\WINDOWS\system32/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\WINDOWS\system32\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pluci\AppData\Local\npm-cache\_logs\2022-06-02T18_35_04_133Z-debug-0.log

CodePudding user response:

Try using the -g flag. Ex: npm install -g npm

From the official npn docs

CodePudding user response:

The issue seems to be that you are in the wrong directory.

It is very unlikely that you would want the System32 directory for your code, as it contains important Windows system files.


To fix this solution, you would most likely need to change your directory using the cd command.

Make sure you run the npm install command in the correct directory where the package.json file exists.

If you don't have a package.json file, run the following command to make a package.json file, and add your dependencies in there.

$ npm init -y

Then, you can run the npm install command without any errors.


In conclusion, the most likely issue with your error is that you are in the wrong directory. You should never do your work in a critical OS directory (e.g. C:\Windows)!

  • Related