We are using git to manage npm-based projects. How can we ensure that node_modules are consistent?

  git, question

Project directory

Git clone's folder/
 ├── node_modules/
 ├── src/

Is it okay if node_modules are placed outside git?

Project directory
 ├── node_modules/
 ├── package.json
 Git (folder from clone)/
 ├── src/
 └── webpack.config.js

The project created by Vue-cli has. gitignore files configured as

.DS_Store
 node_modules/
 dist/
 npm-debug.log*
 yarn-debug.log*
 yarn-error.log*
 
 # Editor directories and files
 .idea
 *.suo
 *.ntvs*
 *.njsproj
 *.sln

This is where the configuration files are not submitted to git.

Npm install is required when you clone a project
This will uniformly install dependencies in package.json