Work with npm Packages with the Wix CLI

Wix allows you to install public npm packages on your site. This article explains how to install, update, and uninstall npm packages in your local IDE with the Wix CLI. You can also use npm packages in the editor or the Wix IDE.

Install an npm package

Before using an npm package, you need to install it on your site.

Important: By installing an npm package, you agree to that npm module's license agreement.

To install a package in your local IDE with the Wix CLI:

  1. Open a terminal to your project's root directory.
  2. Install the package of your choice by running the following command:
    Copy
  3. Open the package.json file in your project to see the installed package.
  4. Learn how to use the installed package from its README file. You can find your package's README file at npmjs.com.

Change a package's version

Using the Wix CLI, you can update an npm package to its latest version. Currently, you can't switch to previous versions of your package using the Wix CLI.

Important: After changing a package's version, make sure that the code on your site is compatible with the updated version of the package.

To update a package to its latest version with the Wix CLI:

  1. Open a terminal to your project's root directory.
  2. Update the package of your choice by running the following command:
    Copy
  3. Open the package.json file in your project to see the package's new version.

Uninstall a package

You can uninstall npm packages that you no longer need.

Warning: When you uninstall a package, make sure to update any code that relies on that package.

To uninstall a package using the Wix CLI:

  1. Open a terminal to your project's root directory.
  2. Uninstall the package of your choice by running the following command:
    Copy
  3. Open the package.json file in your project to see that the package has been removed.

See also

Did this help?