Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is npm init needed?

Tags:

node.js

npm

I always thought that you should initialize npm first before installing any packages

npm init --yes

However I found out that I could just go straight to installing packages

npm i example-package

Then the package would be installed and package.json would be created at the same time.

Is there any reason I should be doing npm init first? Is it only required if I want to specify project details?

like image 310
Hylle Avatar asked Jul 27 '19 06:07

Hylle


1 Answers

It is not required. You can install packages without, and everything will work.

npm init can do basically two things:

  • ask for basic project info to include in packages.json
  • create a specific type of project (for example React) by using npm init typeofproject

If you just want to use packages and don’t care about naming the project or using a template, just install packages.

like image 72
Sami Kuhmonen Avatar answered Nov 13 '22 09:11

Sami Kuhmonen