使用npm创建新项目后,是否应该在package.json中手动更新依赖项版本? [英] Should I manually update dependencies versions in the package.json after creating a new project with npm?

查看:756
本文介绍了使用npm创建新项目后,是否应该在package.json中手动更新依赖项版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了包含Electron和Vuetify框架的样板: https://github.com/vuetifyjs/电子

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

我现在应该手动将package.json中的那些版本更改为最新版本并再次运行npm install吗?

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>

它表明它使用的是最新版本的vuejs(v2.5.13),但使用的是古老版本的节点和电子:

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

  • Electron: 1.7.10,即使在package.json中,我看到的是"electron": "^1.7.5",而最新版本是1.8.2.为什么会这样?

  • 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?

Node: 7.9.0,我什至没有在package.json中看到它.如何将其更新为9.5.0?我想,更新Electron会自动更新节点,这是如何工作的?

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?

推荐答案

就我使用npm-packages而言,可以将npm-package版本手动更改为必需但可用的版本.在package.json中进行更改后,您可以安装依赖项或运行npm install,它将把指定的软件包安装到项目目录中.

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.

代字号(〜)显示特定软件包版本的最右值将递增到已发布的最新可用版本值.简而言之,版本~1.1.2将匹配并且可以更新该特定程序包的所有1.1.X版本,但不会匹配或更新1.2.0版本.虽然~1.2会匹配,并且最多可以更新到1.2.*1.X.*.

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.*.

使用脱字号(^)可以将程序包更新到最新的主要版本(参考程序包版本的第一个数字).即^1.1.2将匹配任何1.x.x版本,包括1.2.0,但不匹配或更新2.0.0.

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.

这篇关于使用npm创建新项目后,是否应该在package.json中手动更新依赖项版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆