jupyter labextension install fails with 'not a valid npm package' error
Fixes `jupyter labextension install` failing with 'not a valid npm package': JupyterLab 3+ uses prebuilt pip packages, not labextension installs. Install the extension with pip instead. Not for extensions that fail to build from source.
TL;DR
jupyter labextension install expects a source-style npm package, but since JupyterLab 3 almost every extension ships as a prebuilt pip or conda package, so the installer rejects it as not a valid npm package. Use pip install [extension-name] instead, then rebuild is unnecessary: prebuilt extensions load on next Lab start. Only reach for labextension install when the docs explicitly say the extension has no prebuilt distribution.
jupyter labextension install fails with 'not a valid npm package' errorUse this when
jupyter labextension install [name]fails with 'not a valid npm package'.- You are on JupyterLab 3 or 4 and following an old tutorial.
- The extension's docs mention
pip installas the install method.
Not for this skill when
- You are developing an extension from source. Then
labextension developis the right tool. - The extension installs but does not appear. That is a build or version-mismatch issue.
Steps
- Check your Lab version:
jupyter lab --version. Verify: 3.x or 4.x, where prebuilt extensions are the norm. - Install via pip:
pip install [extension-package-name]. Verify:pip show [extension-package-name]reports it. - Confirm Lab sees it:
jupyter labextension list. Verify: the extension appears as enabled without a build step. - Restart JupyterLab and open the Extension Manager. Verify: the extension loads and its UI appears.
- If the extension truly has no prebuilt package, clone its repo and use
jupyter labextension develop . --overwritefrom the source dir. Verify: the develop install links instead of erroring.
Variant phrasings
labextension not a valid npm package
Short form. pip install is the answer.
jupyter lab install extension npm error
General phrasing. Same JupyterLab 3 packaging change.
labextension install fails jupyterlab 4
Version-tagged phrasing. Prebuilt extensions only.
Compatibility: JupyterLab 3.x and 4.x. JupyterLab 2 and earlier still used labextension install with npm packages.
Why it happens
JupyterLab 3 introduced the prebuilt extension system: extensions ship compiled frontend assets inside a normal python package, so pip handles everything and no node build is needed. The old labextension install path expects an npm source package layout, which prebuilt distributions do not have, hence the 'not a valid npm package' rejection. Tutorials written for Lab 2 never got updated.
Edge cases / pitfalls
- The pip package name and the labextension name often differ. Check the extension's README for the exact pip name.
- Installing the extension into the server env when Lab runs from another env does nothing. Match the Lab environment.
- Some extensions need a matching
jupyter_serverversion range. Read the extension's requirements before blaming the install.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_7p8ehkjKy30JmbPUAc28eA