11

So oddly I really cannot find the answer to this question and after a few posts and docs I've looked at on NPM I've decided to ask the question - which may be a very basic one but doesn't seem to be implicitly addressed...

How do you uninstall npm from a dir?

Premis:

you npm init -y on the wrong directory

desired outcome:

to remove npm from that directory

I'm working on windows 10 / using git bash on VS code terminal

any help here would be appreciated -

Wally

Kamen Minkov
  • 3,324
  • 1
  • 14
  • 21
Wally
  • 705
  • 1
  • 9
  • 24

2 Answers2

15

All npm init does is setting up package.json for you (guided or not). If you just del package.json from the wrong directory, you should be good to go.

Kamen Minkov
  • 3,324
  • 1
  • 14
  • 21
  • Hi Kamen - thanks for the answer - such a basic solution, I would have thought that npm init would have done something more behind the scenes, so is npm init even necessary - or could you just create a package.json file manually? – Wally May 28 '20 at 10:10
  • It's the same, `npm init` is just a way of doing it through the CLI. If you call it with `-y`, it will just init with default values with no other input from you, otherwise it will go through the needed params and ask you to input values. – Kamen Minkov May 28 '20 at 10:13
  • '-f' or '-y' ... ok thank you for the input - I know its a very basic question – Wally May 28 '20 at 10:16
  • 1
    Not sure if I'm looking at the right thing, but it seems that all four (`-f`, `--force`, `-y`, `--yes`) are the same: https://github.com/npm/init-package-json/blob/latest/init-package-json.js#L18 – Kamen Minkov May 28 '20 at 12:54
4

Deleting the package.json from the wrong directory should do the trick.

You will have to keep in mind that if in case you have run the npm i or npm install commands after npm init you will also have to delete the node_modules folder (as it usually takes plenty of disk space) and run npm i now in the correct directory.