Last updated: Apr 4, 2024
Reading timeยท3 min
Use the npx webpack --version
command to check which version of Webpack is
installed. The command outputs the version number of webpack
, webpack-cli
and webpack-dev-server
.
Open your terminal in your project's root directory and run the following command.
npx webpack --version # ๐๏ธ same as above npx webpack -v
You can use the npx webpack --help
command to list the available commands.
npx webpack --help
webpack
commands with npx
.You can also use the npm ls
command to check your locally installed webpack
version.
npm ls webpack npm ls webpack-cli npm ls webpack-dev-server
You can check the version of webpack
without its dependencies by setting the
--depth
argument to 0
.
npm ls webpack --depth=0 npm ls webpack-cli --depth=0 npm ls webpack-dev-server --depth=0
webpack
moduleIf you need to check the version of a globally installed webpack
package, use
the npm ls -g webpack
command.
# ๐๏ธ check which version of `webpack` is installed globally npm ls -g webpack # ๐๏ธ list the versions of all globally installed packages npm ls -g
webpack
in your package.json
fileYou can also check the version of your locally installed webpack
packages in
the devDependencies
object in your package.json
file.
If you need to install webpack
locally to your project, open your terminal in
your project's root directory and run the following command.
# ๐๏ธ install webpack npm install webpack --save-dev # ๐๏ธ install the latest version of `webpack` npm install webpack@latest --save-dev
if you get an error when running the command, you can repeat it with the
--legacy-peer-deps
flag.
# ๐๏ธ install webpack npm install webpack --save-dev --legacy-peer-deps # ๐๏ธ install the latest version of webpack npm install webpack@latest --save-dev --legacy-peer-deps
webpack
versionsIf you need to get the latest version of webpack
, use the
npm view webpack version
command.
npm view webpack version
If you want to list all versions of the webpack
package, use the
npm view webpack versions
command.
npm view webpack versions npm view webpack versions --json
If you want to install a specific version of webpack
, use the @
symbol to
specify the version.
npm install webpack@5.75.0 --save-dev # ๐๏ธ if you get an error npm install webpack@5.75.0 --save-dev --legacy-peer-deps
If you need to update webpack
to the latest version, use the following
command.
npm install webpack@latest --save-dev # ๐๏ธ if you get an error npm install webpack@latest --save-dev --legacy-peer-deps
You can use the npm outdated
command to list the current version and the
latest version of your npm
packages.
npm outdated
You can use the npm update
command to update your locally installed packages
or the npm update -g
command to update your globally installed NPM packages.
# ๐๏ธ update ALL locally installed packages npm update # ๐๏ธ update ALL globally installed packages npm update -g
The npm update
command follows the version constraints specified in your
package.json
file.
If you want to update all packages in your project to the latest version, use the npm-check-updates package.
Open your terminal in your project's root directory (where your package.json
file is) and run the following command.
package.json
file to version control (e.g. git
) because the following 2 commands will update the versions of your packages in your package.json
file.npx npm-check-updates -u npm install --legacy-peer-deps
The commands update all package versions in your package.json
file to the
latest version and install the packages.