Node update a specific package

Javascriptnode.jsNpmGulpBrowser Sync

Javascript Problem Overview


I want to update my Browser-sync without updating all my node packages. How can I achieve this? My current version of Browser-sync does not have the Browser-sync GUI :(

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

Javascript Solutions


Solution 1 - Javascript

Most of the time you can just npm update (or pnpm update or yarn upgrade) a module to get the latest non breaking changes (respecting the semver specified in your package.json) (<-- read that last part again).

npm update browser-sync
-------
pnpm update browser-sync
-------
yarn upgrade browser-sync

> - Use [p]npm|yarn outdated to see which modules have newer versions > - Use [p]npm update|yarn upgrade (without a package name) to update all modules

Major version upgrades:

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
-------
pnpm add 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
-------
pnpm add 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
-------
pnpm add 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 > ------- > pnpm remove browser-sync --save-dev > pnpm add 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.

Solution 2 - Javascript

Use npm outdated to see Current and Latest version of all packages.


Then npm i packageName@versionNumber to install specific version : example npm i [email protected].

Or npm i packageName@latest to install latest version : example npm i browser-sync@latest.

Solution 3 - Javascript

NPM

Update Specific Package to the Latest Version:

npm update browser-sync

Update a Package By Version:

npm view browser-sync versions (view package version)

npm install browser-sync@2

Update all packages to the latest versions:

npm outdated (this checks the registry to see if any installed packages are currently outdated)

npm update --save/--save-dev (updates and saves dependencies in package.json)

Run a security audit for all the packages:

npm audit (submits a description of the dependencies configured in your project to your default registry and asks for a report of known vulnerabilities) npm audit fix (fix vulnerabilities)

Yarn

Updates all packages to the latest version:

yarn upgrade

Updates specific package to the latest version:

yarn upgrade browser-sync

Updates specific package to specific version:

yarn upgrade browser-sync@^2

Pnpm

Updates all dependencies, adhering to ranges specified in package.json:

pnpm up (alias of pnpm update)

Updates all dependencies, ignoring ranges specified in package.json:

pnpm up --latest

Updates browser-sync to the latest version on v2:

pnpm up browser-sync@2

Updates all dependencies under the @babel scope:

pnpm up "@babel/*"

Solution 4 - Javascript

The legacy-peer-deps command can be helpful as well, especially if you're dealing with some dependency issues and whatnot.

Example: If the package is ngx-multi-window and it's on version 0.3.1

You would run: npm install [email protected] --legacy-peer-deps

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSamuelView Question on Stackoverflow
Solution 1 - JavascriptRyan WhealeView Answer on Stackoverflow
Solution 2 - JavascriptQui-Gon JinnView Answer on Stackoverflow
Solution 3 - JavascriptStas SorokinView Answer on Stackoverflow
Solution 4 - JavascriptDanView Answer on Stackoverflow