Hello everyone!
I’ve been starting to look at Jupyterlab/Jupyterlite recently and I am very interested in developing my own extension.
However, i’ve been struggling a lot with the dependencies of extensions. I appreciate the fact there are a lot of examples in Github to look at and start from. But when I try to build many of them I get dependencies/build errors.
For example in this great repository with many extensions: GitHub - jupyterlab/extension-examples: JupyterLab Extensions by Examples;
I haven’t been able to build any of them. For example for the react-widget one, running npm install
gives me the following error:
npm install
npm WARN deprecated crypto@1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm ERR! code 1
npm ERR! path /Users/thibaut/Documents/extension-examples/react-widget
npm ERR! command failed
npm ERR! command sh -c jlpm run clean && jlpm run build:prod
npm ERR! yarn run v1.21.1
npm ERR! $ jlpm run clean:lib
npm ERR! $ rimraf lib tsconfig.tsbuildinfo
npm ERR! Done in 0.60s.
npm ERR! yarn run v1.21.1
npm ERR! $ jlpm run clean && jlpm run build:lib && jlpm run build:labextension
npm ERR! $ jlpm run clean:lib
npm ERR! $ rimraf lib tsconfig.tsbuildinfo
npm ERR! $ tsc
npm ERR! ../node_modules/@jupyterlab/rendermime/lib/widgets.d.ts(8,31): error TS2420: Class 'RenderedCommon' incorrectly implements interface 'IRenderer'.
npm ERR! The types of 'title.owner.layout' are incompatible between these types.
npm ERR! Type 'import("/Users/thibaut/Documents/extension-examples/node_modules/@lumino/widgets/types/layout").Layout' is not assignable to type 'import("/Users/*****/Documents/extension-examples/node_modules/@jupyterlab/rendermime-interfaces/node_modules/@lumino/widgets/types/layout").Layout'.
npm ERR! Property '[Symbol.iterator]' is missing in type 'import("/Users/*****/Documents/extension-examples/node_modules/@lumino/widgets/types/layout").Layout' but required in type 'import("/Users/*****/Documents/extension-examples/node_modules/@jupyterlab/rendermime-interfaces/node_modules/@lumino/widgets/types/layout").Layout'.
npm ERR! info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! error Command failed with exit code 1.
I actually got the same error while trying to build different extensions. My guess is, it’s probably a version mismatch, or something to do with the versions in the package.json:
"dependencies": {
"@jupyterlab/application": "^3.1.0",
"@jupyterlab/launcher": "^3.1.0",
"@jupyterlab/ui-components": "^3.1.0"
},
"devDependencies": {
"@jupyterlab/builder": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jsdoc": "^40.0.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.18.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"rimraf": "^3.0.2",
"typescript": "~4.1.3"
},
After trying several versions, I unfortunately haven’t been able to find a fix it for me at the moment. I’m far from being a javascript package management expert.
So, would you have any tips for me about how to handle versions/dependencies while developing Jupyterlab/Jupyterlite extensions? Are there any best-practices to follow? How do you deal with the multitude of versions between Jupyterlab and the plethora of extensions out there (and yes I’m using Python environment or conda envs).
I’m on MacOS, using Python 3.11.3, npm v9.6.6, node v16.18
Thank you in advance,
Thibaut