0

Consider this scenario: I installed some packages like jquery and bootstrap with npm install.

After this npp make a package-lock.json file that describes installed package info.

When I push folder project to git server node_modules folder wasn't sent because of gitignore and only json file is placed on server. If someone clone this repo he only has json file. How we can restore or reinstall all dependencies from package-lock.json file? I tried npm install, npm ci, npm i but nothing restored. Any idea?

Farsheef F
  • 11
  • 1
  • 3

1 Answers1

1

Simply you need to run 'npm i' from your project folder. Also make sure, that all your dependencies are in your package.json file. And you need to track changes in your package.json file in future, because commiting 'node_modules' is a real bag thing. it will be always ignored by *.gitignore settings. Also use "npm i %package% --save" to add current package to package.json.

Paul Zaslavskij
  • 638
  • 3
  • 9
  • Create a folder. Run```npm install bootstrap```. Then remove node module folder. Now with a package-lock.json how you can restore bootstrap? – Farsheef F Apr 01 '20 at 17:11
  • Running `npm install`, as Paul suggested, will restore the files in the `package-lock.json` by default. You can read more in the documentation at https://docs.npmjs.com/configuring-npm/package-locks.html. – Cameron Little Apr 01 '20 at 17:33