npmnpm-installnpm-startnpm-init

Do I have to do npm init, npm start and npm install each time?


I'm using npm for a local project.

I want to know if I have to use npm init every time I start a session. I think the answer is yes.

For example, if I restart my machine, do I have to do npm init?

Do I have to do npm install and npm start each time?


Solution

  • 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.