Should I manually update dependencies versions in

2019-08-28 13:24发布

问题:

I've installed this boilerplate with Electron and Vuetify frameworks included: https://github.com/vuetifyjs/electron

Questions:

Should I now manually change those versions in the package.json to the latest and run npm install again?

 "dependencies": {
    "vue": "^2.4.2",
    "vuetify": "0.17.4",
    "vue-electron": "^1.0.6",
    [...]
  },
  "devDependencies": {
    "electron": "^1.7.5",
    [...]
  }

Why do those dependencies have that ^ symbol if they still don't download the latest version?

The boilerplate has this code in one of the components and it's displaying the installed versions:

<script>
 export default {
    data () {
      return {
        electron: process.versions['atom-shell'],
        node: process.versions.node,
        vue: require('vue/package.json').version
      }
    }
  }
</script>

It shows that it uses the latest version of vuejs (v2.5.13) but ancient versions of node and electron:

  • Electron: 1.7.10 even though in the package.json I see "electron": "^1.7.5" while the latest version is 1.8.2. Why is that?

  • And Node: 7.9.0 which I don't even see it in the package.json. How do I update it to 9.5.0? I suppose, updating Electron will update node automatically, is that how it works?

回答1:

As far as I worked with npm-packages it is possible to manually change the npm-package version to required but available version. Just after making changes in package.json you can install the dependencies or run npm install and it will install the specified package to project directory.

The tilde(~) sign shows that the rightmost value of specific package version will increment upto the latest available version value that was published. In short, the version ~1.1.2 will match and can update upto all 1.1.X versions of that specific package but will not match or update 1.2.0 version. While ~1.2 will match and can update upto 1.2.* through to 1.X.*.

The caret(^) sign allows you to update package to most recent major version (referencing to the first number of package version). i.e. ^1.1.2 will match any 1.x.x release including 1.2.0, but will not match or update 2.0.0.



回答2:

Worked for me:

1. npm update vue

If you got error :

vue-template-compiler and vue should be the same version

then run 2 and 3 step

2. npm uninstall vue-template-compiler 
3. npm install vue-template-compiler