NPM Init and Start

Al Lemieux picture Al Lemieux · Mar 6, 2019 · Viewed 16.4k times · Source

I'm using npm for a local project and I want to know if I have to use npm init every time I start a session? I think the answer is yes.

If I restart my machine for example, do I have to do npm init? Do I have to do npm install and npm start each time?

Thanks

Answer

Evan Winter picture Evan Winter · Mar 6, 2019

No, you only have to do npm init when you're first creating a project. It essentially just creates the package.json file (https://docs.npmjs.com/cli/init.html).

And you should only have to run npm install when you first set up a project for local development, or when changes are made to the project's dependencies. So, usually just once, unless you've made changes. (https://docs.npmjs.com/cli/install.html)

npm start is a script that should be defined in your package.json, and you will likely need to run that every time you begin local development on your project.