【问题标题】:自定义 jupyter labextension 无法安装
【发布时间】:2022-01-17 19:04:52
【问题描述】:

我们有一个自定义 jupyterlab 扩展,无法为 nodejs=14.14.0(和 15.2.1)安装(使用 conda 安装)。

以下是 labextension 的 package.json 文件的样子:

{
    "name": "my-custom-ext",
    "version": "0.1.0",
    "description": "Integrate JupyterLab with ext",
    "keywords": [
        "jupyter",
        "jupyterlab",
        "jupyterlab-extension"
    ],
    "homepage": "https://github.com/my_name/myextension",
    "bugs": {
        "url": "https://github.com/my_name/myextension/issues"
    },
    "license": "BSD-3-Clause",
    "author": "xyz",
    "files": [
        "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
        "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
    ],
    "main": "lib/index.js",
    "types": "lib/index.d.ts",
    "repository": {
        "type": "git",
        "url": "https://github.com/my_name/myextension.git"
    },
    "scripts": {
        "build": "tsc",
        "clean": "rimraf lib",
        "prepare": "npm run clean && npm run build",
        "watch": "tsc -w"
    },
    "dependencies": {
        "@jupyterlab/application": "^3.0.6",
        "@jupyterlab/apputils": "^3.0.5",
        "@jupyterlab/coreutils": "^5.0.3",
        "@jupyterlab/docregistry": "^3.0.6",
        "@jupyterlab/launcher": "^3.0.5",
        "@jupyterlab/mainmenu": "^3.0.5",
        "@jupyterlab/notebook": "^3.0.6",
        "@jupyterlab/services": "^6.0.5",
        "@lumino/commands": "^1.12.0",
        "@lumino/coreutils": "^1.5.3",
        "@lumino/disposable": "^1.4.3",
        "@lumino/widgets": "^1.16.1"
   
    },
    "devDependencies": {
        "@jupyterlab/builder": "^3.0.0",
        "rimraf": "^3.0.2",
        "typescript": "~4.1.3"
    },
    "jupyterlab": {
        "extension": true
    }
}

这是错误jupyter labextension install --no-build my-custom-ext

Node v14.14.0

Yarn configuration loaded.
> node /opt/conda/lib/python3.8/site-packages/jupyterlab/staging/yarn.js install
-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-yarn install v1.21.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning @blueprintjs/core@3.52.0: Invalid bin entry for "upgrade-blueprint-2.0.0-rename" (in "@blueprintjs/core").
warning @blueprintjs/core@3.52.0: Invalid bin entry for "upgrade-blueprint-3.0.0-rename" (in "@blueprintjs/core").
error @npmcli/fs@1.1.0: The engine "node" is incompatible with this module. Expected version "^12.13.0 || ^14.15.0 || >=16". Got "14.14.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

> /opt/conda/bin/npm pack /home/jovyan/my-custom-ext

-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-
> my-custom-ext@0.1.0 prepare /home/jovyan/my-custom-ext
> npm run clean && npm run build


> my-custom-ext@0.1.0 clean /home/jovyan/my-custom-ext
> rimraf lib


> my-custom-ext@0.1.0 build /home/jovyan/my-custom-ext
> tsc

src/index.ts(1,72): error TS2307: Cannot find module '@jupyterlab/apputils' or its corresponding type declarations.
....
....
....
ValueError: "/home/jovyan/my-custom-ext" is not a valid npm package

Exiting application: lab

运行“npm ls”我得到了:

├─┬ @jupyterlab/builder@3.2.5
│ ├─┬ terser-webpack-plugin@4.2.3
│ │ ├─┬ cacache@15.3.0
│ │ │ ├─┬ @npmcli/fs@1.1.0

将 package.json 更改为:

"devDependencies": {
        "@jupyterlab/builder": "=3.2.4",......

但这并没有帮助。还是一样的错误

注意:https://www.npmjs.com/package/@npmcli/fs:1.1.0 发布于 5 天前。

请帮忙解决一下

【问题讨论】:

    标签: node.js npm version package.json jupyter-lab


    【解决方案1】:

    这个片段是相关的:

    Expected version "^12.13.0 || ^14.15.0 || >=16". Got "14.14.0"
    

    它告诉您需要使用节点14.15.0 或更新的 14.x,并且您不能使用 13.x、15.x。但是你有14.14.0 - 这意味着你需要升级你的node.js。

    您提到 conda - 可能是您使用了过时的默认频道,因此您获得了 14.x 的旧次要版本; conda-forge 频道有所有版本,我建议切换到它。如果您已经使用conda-forge 并且无法获得更新的版本,您可能想尝试使用mamba,因为它有更好的依赖解析器。

    注意:无论如何,JupyterLab 3.x 目前还不能很好地支持 15.x 和更新版本(除其他外,因为并非所有依赖项都升级到 16.x,因为 Node 遵循奇偶版本节奏,其中只有偶数是稳定的足够长的时间让更广泛的生态系统有动力迁移)。

    【讨论】:

    • 谢谢!我们能够通过在自定义扩展项目中添加以前工作的 yarn.lock 文件来解决这个问题。这样它就不会尝试升级任何导致不兼容的东西。
    猜你喜欢
    • 2020-06-22
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-02
    • 1970-01-01
    相关资源
    最近更新 更多