节点更新特定的程序包

JavaScript Node.js

泡芙

2020-03-24

我想更新浏览器同步而不更新所有节点包我该如何实现?我当前的浏览器同步版本没有浏览器同步GUI :(

├─┬ browser-sync@1.9.2
│ ├── browser-sync-client@1.0.2

第3524篇《节点更新特定的程序包》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

2个回答
小胖Gil 2020.03.24

大多数时候,您只需要npm更新(或yarn upgrade)模块即可获得最新的不间断更改(尊重package.json中指定的semver)(<-再次阅读最后一部分)。

npm update browser-sync
-------
yarn upgrade browser-sync
  • npm|yarn outdated看哪个模块有新版本
  • 使用npm update|yarn upgrade(无包名)更新所有模块
  • 包括--save-dev|--dev如果你想更新的版本号保存到您的package.json。 (注意:从npm v5.0开始,仅在时才需要devDependencies)。

主要版本升级:

In your case, it looks like you want the next major version (v2.x.x), which is likely to have breaking changes and you will need to update your app to accommodate those changes. You can install/save the latest 2.x.x by doing:

npm install browser-sync@2 --save-dev
-------
yarn add browser-sync@2 --dev

...or the latest 2.1.x by doing:

npm install browser-sync@2.1 --save-dev
-------
yarn add browser-sync@2.1 --dev

...or the latest and greatest by doing:

npm install browser-sync@latest --save-dev
-------
yarn add browser-sync@latest --dev

Note: the last one is no different than doing this:

npm uninstall browser-sync --save-dev
npm install browser-sync --save-dev
-------
yarn remove browser-sync --dev
yarn add browser-sync --dev

The --save-dev part is important. This will uninstall it, remove the value from your package.json, and then reinstall the latest version and save the new value to your package.json.

宝儿 2020.03.24

始终可以手动进行。这些是步骤:

  • 转到NPM软件包页面,并搜索GitHub链接。
  • 现在使用GitHub下载链接或通过克隆下载最新版本。 git clone github_url
  • 将包复制到您的node_modules文件夹中,例如node_modules/browser-sync

现在它应该为您工作。为确保将来不会中断npm i,请继续执行接下来的两个步骤:

  • 通过读取package.json文件夹中文件来检查新软件包的版本
  • 打开您的项目,package.json并为它在dependencies部分中显示的位置设置相同的版本package.json

不建议您手动进行。有时,最好能了解事物在幕后的工作方式,以便能够修复事物。我发现自己不时这样做。

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android