Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The error error while loading shared libraries: libnspr4.so means the Linux dynamic loader cannot find that shared library when Playwright starts a browser. On Debian- and Ubuntu-family systems, it is provided by the libnspr4 package. Without root access, the most reliable fixes are to have an administrator install Playwright’s required operating-system dependencies or to run the project in an approved Playwright Linux container. Moving the browser download to a user-owned directory will not supply a missing system library.

Check which Playwright dependencies are missing

From your project directory, run the dependency check for the browser you launch:

npx playwright install-deps chromium --dry-run

Replace chromium with firefox or webkit if that is the browser your project uses. Playwright documents that on Linux this command simulates installation through apt-get and exits with a non-zero code if required packages are missing. It is a check, not a repair, and does not install packages. See Playwright’s command-line documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the output to identify the dependency set to resolve. The missing libnspr4.so message does not prove that it is the only missing library; the dependency check may report additional packages.

Choose a fix that works without sudo

Route Host administrator access What to know
Ask an administrator to install dependencies Required for system-wide installation Use the dependency check output and confirm the host distribution and architecture. This is the most direct way to satisfy system-library requirements.
Use an approved Playwright Linux container or environment Not necessarily, if the environment is already provided and permitted Playwright recommends its Docker image for Linux CI agents. Coordinate the image version with the project’s Playwright version and ensure the environment includes the needed browser dependencies. See Playwright’s CI guidance.
Extract packages into a user-owned prefix May avoid installing packages system-wide A third-party article proposes downloading and extracting Debian packages and setting LD_LIBRARY_PATH. This is not official Playwright guidance, and portability or a complete dependency set is not established. Assess compatibility for the host release, architecture, and glibc environment before considering it.

Request the system dependencies from an administrator

Send the administrator the output of the dry run, your Linux distribution and release, CPU architecture, and the Playwright browser you are trying to launch. Ask them to install the reported operating-system dependencies using the host’s supported package manager. On Debian and Ubuntu, package indexes associate libnspr4.so with the libnspr4 package; package names and availability can differ on other distributions. Check the relevant Ubuntu package record rather than assuming Debian/Ubuntu commands apply everywhere.

Playwright’s documented install-deps workflow installs operating-system dependencies, so it generally requires privileges when those packages must be added to the host. The browser download command and dependency installation are separate operations; see Playwright’s browser installation guidance.

Use a container when the host packages cannot be changed

If your organization permits containers, use an approved Playwright Linux image or environment that contains the required browser dependencies. This avoids asking for each library to be installed on an otherwise locked-down host, but it does not remove the need to match the environment to your project. Follow Playwright’s CI guidance and coordinate the image version with the Playwright version used by the project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why changing the browser cache does not fix this error

PLAYWRIGHT_BROWSERS_PATH controls where Playwright stores browser binaries. It does not install or locate operating-system libraries such as libnspr4.so. A browser can be present in a user-owned cache and still fail at startup when the host loader cannot find a required shared library. Playwright documents browser storage separately from operating-system dependency installation at its browser documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

About extracting libraries into your home directory

A DEV Community article describes downloading Debian packages, extracting them beneath a home-directory prefix, and setting LD_LIBRARY_PATH. Treat this as an environment-specific workaround, not a supported general fix: a package may depend on other libraries, and compatibility across distribution releases, CPU architectures, and glibc environments is not established by that article alone.

  • Do not copy arbitrary shared-object files from another machine or distribution.
  • Do not create compatibility symlinks unless you have verified the library ABI; a matching filename does not guarantee compatibility.
  • If you evaluate a local prefix, verify every transitive dependency and test it in the same environment where the browser will run.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.