What does npm init command do and when would you use it?

Experience Level: Junior
Tags: npm

Answer

The command npm init creates a file package.json.

You can use it whenever you need to create a new Node.js project. When the file exists, you can add a dependency or devDependency to the file and install it using npm.

Related npm job interview questions
npm for beginners
npm for beginners

Are you learning npm? Try our test we designed to help you progress faster.

Test yourself