0

I have tried installing in a couple ways...

npm install -S vue@*
npm install -S vue@latest

However, in the package.json they don't use * or latest, there is an actual version. I also don't want to have to manually edit this for each dependency. I also don't want to have to run an upgrade command in npm, I want it to be latest from initial install. How do I install in a way where the version is declared latest or *?

Jackie
  • 21,969
  • 32
  • 147
  • 289

2 Answers2

0

To get the latest version of Vue into your dependencies do the following:

1) Remove ^ from the current version listed in package.json. ^ is the default semantic versioning used to lock your versions in place to avoid breaking changes.

2) run npm update -s vue to update your vue version to current.

Len Joseph
  • 1,406
  • 10
  • 21
  • Sorry this isn't what I was looking for I want the npm install command to USE latest I don't want to manually edit the package.json. I will make this clearer in the question. – Jackie Jun 10 '19 at 14:41
  • Gotcha, this may be helpful: https://stackoverflow.com/questions/43127863/node-update-a-specific-package – Len Joseph Jun 10 '19 at 14:50
  • Meh, so I guess I am stuck just editing the file. It is strange there isn't a feature for this, maybe I should open an issue with node. – Jackie Jun 10 '19 at 15:56
  • I would argue the inconvenience is worth the security in this case. It would be too easy to accidentally create breaking changes through an unintended major version upgrade, otherwise. For example, if you generated your project with `vue init` (from Vue CLI v2), there are likely webpack incompatibilities with a major version change of Vue in your project. – Len Joseph Jun 10 '19 at 15:57
  • I prefer breaking changes due to upgrades. That is what the package-lock is for in my case for released versions. If an upgrade of a library breaks my app I typically want to know about it so I can make the call to either fix the issue or declare a version for now. – Jackie Jun 10 '19 at 16:02
  • Also I am not using webpack I am using the ESM version. "import Vue from '/vue/vue.esm.browser.js'" – Jackie Jun 10 '19 at 16:03
0

There's no such feature in npm. You could use/alias a shell one-liner though

NPM_INSTALL=vue node -e "const fs = require('fs').promises; (async () => {const pj = JSON.parse(await fs.readFile('./package.json')); pj.dependencies[process.env.NPM_INSTALL] = '*'; fs.writeFile('./package.json', JSON.stringify(pj, null, 2))})()" && npm install

Another possibility might be to use npm-check-updates, which lets you upgrade all dependencies to the latest version with one command: ncu -u

stoically
  • 58
  • 5