简体   繁体   English

为什么有时我的Nodejs会自动升级到最新版本的Nodejs?

[英]Why my Nodejs gets automatically upgraded to the latest version of Nodejs after sometime?

I have a previous version of node installed but after few days it gets automatically updated to the latest version. 我安装了节点的先前版本,但几天后它会自动更新为最新版本。 I do not want it to upgrade itself to a newer version. 我不希望它自己升级到新版本。

You need to specify the exact node version in your package.json file. 您需要在package.json文件中指定确切的节点版本。

A bit of background, from the NPM documentation : NPM文档提供了一些背景知识:

It's important to communicate the extent of changes in a new release of code, because sometimes updates can break code that a package needs (called dependencies).Semantic versioning (semver) is a standard that was designed to solve this problem. 在新版本的代码中传达更改的范围很重要因为有时更新可能会破坏程序包所需的代码 (称为依赖项)。语义版本控制(Semver)是旨在解决此问题的标准。

  1. From your terminal, type node --version ; 在您的终端中,输入node --version ; you will get a number formatted as XXX 您将获得一个格式为XXX的数字
  2. Open your package.json file and remove any ~ or ^ signs from the node version you want to use so that it won't update to any minor or batch changes. 打开您的package.json文件,并从要使用的节点版本中删除任何~^符号,以使其不会更新为任何次要或批量更改。
  3. enter npm install in your terminal again and you are done. 再次在终端中输入npm install ,您就完成了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM