1

I'm scaffolding the vue app frontend using webpack:

vue init webpack frontend
cd frontend

For this app, I need - among others - axios, hence:

npm install axios

Now I push the code to the repo and clone the repo from another computer.

My question is:

How do I make sure all the required npm libraries are there on the new computer so that npm run build succeeds?

Markus
  • 522
  • 5
  • 21
  • 2
    Check in the `node_modules` folder. Though I would [recommend against it for various reasons](https://stackoverflow.com/questions/18128863/should-node-modules-folder-be-included-in-the-git-repository) – Liam Oct 22 '18 at 16:02

1 Answers1

3

When you check out the repo on a new system, you will run

npm install

to fetch all the node_modules associated with the project. Make sure your package-lock.json was checked into git so that you will be guaranteed to fetch the exact same versions as were intended in the commit.

Ian MacDonald
  • 11,433
  • 1
  • 21
  • 41
  • 1
    Good answer, but I believe OP needs to add `--save` to their `npm install axios` call to get it to show up in `package-lock.json`. – ceejayoz Oct 22 '18 at 16:12
  • 2
    Thanks for the tip! I did a research and found: "as of npm 5.0.0 `--save` is the default", see https://stackoverflow.com/questions/19578796/what-is-the-save-option-for-npm-install – Markus Oct 22 '18 at 16:32
  • For the difference between checking in `package-lock.json` and `package.json` see Xin's answer here: https://stackoverflow.com/questions/44206782/do-i-commit-the-package-lock-json-file-created-by-npm-5 – Markus Oct 22 '18 at 16:51