找不到模块:错误无法解析“child_process”,如何修复?

2023-11-30

我正在尝试创建一个 JupyterLab 扩展,它使用打字稿。

我已经成功添加了包“@types/node”,允许我使用“require('http')”等包。

但是,一旦我尝试使用子进程,使用“require(“child_process”)”,我在尝试构建扩展时会收到以下错误。

ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/lib'
    at factory.create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/Compilation.js:535:10)
    at factory (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:397:22)
    at resolver (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
    at asyncLib.parallel (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
    at /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/neo-async/async.js:2825:7
    at /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/neo-async/async.js:6886:13
    at normalResolver.resolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
    at doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:184:12)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:5)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:12:1)
    at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:42:38)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn41 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:381:1)
    at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:23:37)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at args (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/forEachBail.js:30:14)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:5)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5) resolve 'child_process' in '/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/lib' Parsed request is a module   using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/package.json (relative path: ./lib)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/lib/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/envs/jupyterlab-ext/share/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/envs/jupyterlab-ext/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/envs/node_modules doesn't exist or is not a directory
      /home/fionn/anaconda3/node_modules doesn't exist or is not a directory
      /home/fionn/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules
        using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
      looking for modules in /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules
        using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: .)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
          using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/package.json (relative path: ./node_modules/child_process)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process is not a file
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.json doesn't exist
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.json doesn't exist
            as directory
              existing directory
                use ./index.js from main in package.json
                  using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: .)
                    Field 'browser' doesn't contain a valid alias configuration
            as directory
              /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process doesn't exist
                    using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: ./index.js)
                      no extension
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js doesn't exist
                      .wasm
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.wasm doesn't exist
                      .mjs
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.mjs doesn't exist
                      .js
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.js doesn't exist
                      .json
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.json doesn't exist
                      as directory
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js doesn't exist
                using path: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index
                  using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: ./index)
                    no extension
                      Field 'browser' doesn't contain a valid alias configuration
                      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index doesn't exist
                    .wasm
                      Field 'browser' doesn't contain a valid alias configuration
                      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.wasm doesn't exist
                    .mjs
                      Field 'browser' doesn't contain a valid alias configuration
                      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.mjs doesn't exist
                    .js
                      Field 'browser' doesn't contain a valid alias configuration
                      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js doesn't exist
                    .json
                      Field 'browser' doesn't contain a valid alias configuration
                      /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.json doesn't exist error Command failed with exit code 1.

我已经用谷歌搜索过,但仍然不知道如何解决这个问题。

任何指示或信息都将不胜感激。

我的packages.json 文件。

{
  "name": "jupyerlab_xkdc",
  "version": "0.1.0",
  "description": "Short description",
  "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": "Fionn McKnight",
  "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": "^0.19.1",
    "@jupyterlab/apputils": "^0.19.1",
    "@phosphor/coreutils": "^1.3.0",
    "@phosphor/messaging": "^1.2.2",
    "@phosphor/widgets": "^1.6.0",
    "@types/jquery": "^3.3.29",
    "@types/node": "^10.12.19",
    "child_process": "^1.0.2",
    "npm": "^6.7.0"
  },
  "devDependencies": {
    "@types/node": "^10.12.19",
    "rimraf": "^2.6.1",
    "typescript": "~3.1.1"
  },
  "jupyterlab": {
    "extension": true
  }
}

只需放入 package.json

"browser":{
"child_process": false
}  

你在使用 webpack 吗

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

找不到模块:错误无法解析“child_process”,如何修复? 的相关文章

随机推荐

  • 如何回滚文件 git vscode 以前的历史记录?

    如何在vscode中重新加载git源代码管理中文件的先前历史记录 vs code 只提供恢复最后一次提交的功能 我可以在 vscode 中看到带有 Git History 扩展名的文件的所有历史记录 但是有没有办法回滚到文件的任何历史记录
  • 如何在 Java 中将示例 JSON 转换为 JSON 模式

    我想将 json 文档转换为 json 模式 我用谷歌搜索了它 但没有根据我的要求得到确切的想法 这是 JSON empId 1001 firstName jonh lastName Springer title Engineer addr
  • gdb 调试器中未找到调试符号

    当我运行复杂的 C 程序模拟器 c 其中包含 gdb 中的许多 C 文件 时 它会给出错误 找不到调试符号 我正在使用 gcc g Simulator c 来编译这个程序 任何人都可以告诉我为什么会出现这个错误 您可能需要编译each c
  • Vue实例之间如何通信

    如果我定义一个组件 例如 Vue component hello name hello data gt return color black template div div TEST div div
  • 通过 NuGet 提供 App.config 文件

    我的 nupkg 中有一些信息 我想将其包含在消费者的应用程序中 使用 nupkg 时直接包含部分 app config 的最佳方法是什么 我目前已经这样做了 mypackage nupkg content 应用程序配置 但这使得它想要覆盖
  • 在 Enzyme / React 测试中什么时候应该使用 render 和shallow?

    在发布这个问题之前 我尝试在 sqa stackexchange 中搜索 但我在那里没有找到关于浅层和渲染的帖子 所以我希望有人可以在这里帮助我 在测试 React 组件时我什么时候应该使用shallow 和 render 根据airbnb
  • 当用户名错误时,为什么 GetErrorMessage 返回“密码错误”?

    获取错误消息 来自 CInternetException 给了我以下内容 FTP 服务器名称不正确 错误 无法解析服务器名称或地址 密码错误 错误 密码不被允许 用户名不正确 错误 密码不被允许 try pConnect sess gt G
  • 有效地将命名列表转换为 data.frame [重复]

    这个问题在这里已经有答案了 我正在寻找一种有效的方法来进行以下转换 输入示例 ob lt list a 2 b 3 预期输出 key value 1 a 2 2 b 3 当前 详细 解决方案 data frame key names ob
  • JavaScript 中 const 和 const {} 有什么区别?

    当我学习时Electron 我发现了两种获取 BrowserWindow 对象的方法 const BrowserWindow require electron and const electron require electron cons
  • 文件打开、文件读取、文件写入

    如何正确使用文件读取 文件写入 缓冲区 或 TFileStream 我需要将整个文本文件读取到字符串中 然后将字符串写回到该文件中 用新字符串替换它 TStringList如果您需要按行处理文件 这就是您想要的 如果您只想将其视为单个字符串
  • 为什么 termcolor 在 Windows 控制台中输出控制字符而不是彩色文本?

    我刚刚安装术语颜色适用于 Windows 上的 Python 2 7 当我尝试打印彩色文本时 我得到的是颜色代码 from termcolor import colored print colored Text text text red
  • 刷新页面上的Javascript而不刷新HTML

    关于我的问题的一些背景信息 我正在更新当前显示 HTML 的 div 中的 MathML 当我第一次加载页面时 如果运行 MathJax 脚本并完美显示所有 MathML 当我单击 预览更改 一个按钮 该按钮获取文本区域中所做的当前更改并将
  • Flutter的全球主流飞镖未来如何等待?

    我使用 dart meteor 包 并且必须在全球范围内发起main dart 像这样 import package flutter material dart import package dart meteor dart meteor
  • PHP include() 在 doctype 之前,导致空格

    我的网站存在空白问题 我在文档类型之前包含了一些文件 这会导致输出空白 经过搜索我找到了这个解决方案 文档类型前的空格问题 然而去掉之后 gt 我仍然遇到问题 下面是代码 Here is session php
  • 正则表达式匹配科学记数法

    我正在尝试匹配科学记数法中的数字 正则表达式来自here scinot re compile 0 1 9 d d eE d re findall scinot x 1e4 1e4 re findall scinot x c1e4 1e4 我
  • 如何持续监控LogCat文件?

    我需要以某种方式监视 LogCat 日志 这意味着当我的服务运行时 我需要读取 LogCat 中的新条目 目前我只知道如何检索一次日志 Process mLogcatProc null BufferedReader reader null
  • 获取内核代码中的当前工作目录

    我正在开发一个项目 在该项目中我需要知道调用系统调用的可执行文件的当前工作目录 我认为这是可能的 因为某些系统调用就像open将利用该信息 您能告诉我如何获取字符串中的当前工作目录路径吗 你可以看看如何getcwd系统调用的实现是为了看看如
  • itext 马拉地语(印度)语言显示问题

    我正在评估 iText 作为 java swing 应用程序的 PDFGenerator 输出应该是 马拉地语 这是一种与印地语类似但不相同的印度当地语言 出于评估目的 这是我要打印的文本 这是源代码 package pdftest imp
  • 为什么这个iPhone程序不调用-loadView?

    我正在尝试完成基本的 iPhone 编程 并且我对 Interface Builder 的工作原理有很好的基本了解 因此我决定尝试以编程方式制作视图 我已经浏览了 ViewController Apple 指南并到处搜索 但似乎找不到解决我
  • 找不到模块:错误无法解析“child_process”,如何修复?

    我正在尝试创建一个 JupyterLab 扩展 它使用打字稿 我已经成功添加了包 types node 允许我使用 require http 等包 但是 一旦我尝试使用子进程 使用 require child process 我在尝试构建扩