Home > OS >  What happens if you run “npm init” twice on same folder?
What happens if you run “npm init” twice on same folder?

Time:10-06

I understand the command initialises a package.json file in the CWD, I’m just curious what happens behind the scenes if the package.json file already exists.

I couldn’t find it in documentation and didn’t notice anything different when I ran it. Does the code stop once it detects a package.json file to stop overwriting what’s already there?

I'm just trying to learn more about the inner workings of this command.

CodePudding user response:

Running 'npm init' will just reinitialize the package.json based on the new inputs you perform. Therefore, you're doing basically the same you did when first calling 'npm init'

See the enter image description here

now npm init again

enter image description here

CodePudding user response:

It will run through and overwrite the Stuff you can edit with npm init. The rest stays untouched.

  • Related