我正在尝试创建一个JupyterLab扩展,它使用typescript。
我已经成功地添加了包“@类型/节点”,允许我使用诸如“要求”(“超文本传输协议”)这样的包。
但一旦我尝试使用子进程,使用“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.
我在谷歌上搜索过,但仍然不知道如何解决这个问题。
如有任何提示或信息,将不胜感激。
我的包裹。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
}
}
在我使用的新版本中:
// webpack.config.js
...,
resolve: {
extensions: [".ts", ".js"],
fallback: {
"child_process": false,
// and also other packages that are not found
}
},
我在尝试运行故事书时遇到了类似的错误。js
使用网页包。
您可以将以下内容添加到网页包的配置中以修复生成-
// webpack.config.js
...,
node: {
child_process: "empty"
// fs: "empty", // if unable to resolve "fs"
},
您还可以将其他冲突模块设置为“empty”
,如果它们负责破坏生成。
网页包配置的参考。节点
把它放进包裹里。json
"browser":{
"child_process": false
}
你在用webpack吗
问题内容: 我正在使用Babel和Webpack开发一个React应用,我想使用npm中的软件包。我已经安装了该软件包并将其保存为项目的依赖项。运行npm start后,出现此错误: ./~/file-exists/index.js中的错误找不到 模块:错误:无法在C:\ GitHub \ CryptoPrices \ node_modules \ file-exists @ ./~/file-e
问题内容: 从GitHub提取模块并按照说明进行构建后,我尝试使用以下方法将其拖入现有项目: 这似乎可以解决问题: 但是Node.js找不到模块: 我真的很想了解这里发生的事情,但是对于接下来的去向我有些茫然。有什么建议? 问题答案: 使用仅将模块安装到当前目录中(在名为的子目录中)。app.js位于下面吗?如果不是,并且您想从任何目录使用该模块,则需要使用进行全局安装。 我通常在本地安装大多数软
我已经处理这个错误很长时间了,我尝试了很多方法,但都没有奏效。我在下面列出了我尝试过的方法。请不要再推荐它们。谢谢 我尝试过的方式 cd ios-
项目目录映像 我正在尝试使用以下语法在我的react应用程序中导入firebase: 从.../Firebase/config导入{auth} 但我面临以下问题: ./src/Pages/Login/Login.js模块未找到:无法解决.../Firebase/config 这是我的配置文件 从“/firebase/app”导入*firebase/auth”作为firebase;导入“fireba
当我使用编译代码时,发生了一个错误。 当我尝试使用解决这个问题时,什么都没有发生,问题仍然存在。 以下是错误日志: 内部/模块/cjs/装载机。js:638抛出错误;^错误:在函数处找不到模块“react dev utils/prompt”。模块_函数处的resolveFilename(internal/modules/cjs/loader.js:636:15)。模块_在模块处加载(内部/modu
尝试在android上构建带有react-navigation的react-native v0.61.5应用程序时遇到此错误。iOS运行良好,不知道为什么我会得到这个index.android文件错误,因为我认为react-native将索引文件合并到singular < code > index . js 作为入口点。 这是全部错误: 加载依赖图,完成。错误:无法解析模块<代码>。``中的/in