找不到 express-pouchdb 相关模块 Electron 应用程序

如何解决找不到 express-pouchdb 相关模块 Electron 应用程序

在我的 Electron-React-Typescript-Webpack 应用程序中,我安装了这些包:

"devDependencies":
    "electron": "^12.0.0","typescript": "^4.1.5","@types/node": "^14.14.28","@types/pouchdb-core":` "^7.0.6","@types/pouchdb-find": "^6.3.6","@types/pouchdb-replication": "^6.4.2","webpack": "^5.23.0"

"dependencies":
     "pouchdb": "^7.2.2","pouchdb-adapter-http": "^7.2.2","pouchdb-adapter-idb": "^7.2.2","pouchdb-adapter-leveldb": "^7.2.2","pouchdb-adapter-localstorage": "^7.2.2","pouchdb-adapter-memory": "^7.2.2","pouchdb-adapter-websql": "^7.0.0","pouchdb-all-dbs": "^1.1.1","pouchdb-core": "^7.2.2","pouchdb-debug": "^7.2.1","pouchdb-find": "^7.2.2","pouchdb-replication": "^7.2.2","pouchdb-selector-core": "^7.2.2","pouchdb-utils": "^7.2.2","rxdb": "file:rxdb-local.tgz"

我创建了这个 /src/infopiecesDb.js 文件

const {
    createRxDatabase,addRxPlugin
} = require('rxdb');
addRxPlugin(require('pouchdb-adapter-http'));

const infopieceSchema = {
    title: 'infopiece schema',description: 'describes a simple infopiece',version: 0,type: 'object',properties: {
        id: {
          type: 'number',},doc_path: {
          type: 'string'
        },date: {
          type: 'string'
        },title: {
          type: 'string',primary: true
        },body: {
          type: 'string,'
        }
    },required: ['body']
};

let _getDatabase; // cached
function getDatabase(name,adapter) {
    if (!_getDatabase) _getDatabase = createDatabase(name,adapter);
    return _getDatabase;
}

async function createDatabase(name,adapter) {
    const db = await createRxDatabase({
        name,adapter,password: 'myLongAndStupidPassword'
    });

    console.log('creating infopieces ..');
    await db.collection({
        name: 'infopieces',schema: infopieceSchema
    });

    return db;
}
module.exports = {
    getDatabase
};

/src/main/main.ts 中,我添加了以下几行:

import infopiecesDb from '../rxdb/infopiecesDb';
import { addRxPlugin } from 'rxdb';
addRxPlugin(require('rxdb/plugins/server'));
addRxPlugin(require('pouchdb-adapter-memory'));


app.on('ready',async () => {
  createMainWindow();
  const db = await infopiecesDb.getDatabase(
    'infopiecesdb','memory'
  );
  // spawn a server
  console.log('start server');
  await db.server({
    path: '/db',port: 10102,cors: true
  });
  console.log('started server');
})

正在执行,应用程序打开,但我收到此消息:

yarn start electron --trace-warnings ...
yarn run v1.22.5
$ yarn run build && electron ./dist/main/main.js electron --trace-warnings ...
$ npx webpack --config ./webpack.config.js
asset main.js 3.3 MiB [compared for emit] (name: main)
orphan modules 263 KiB [orphan] 138 modules
runtime modules 1.06 KiB 6 modules
modules by path ./node_modules/ 2.54 MiB
  javascript modules 2.17 MiB 382 modules
  json modules 376 KiB
    modules by path ./node_modules/iconv-lite/encodings/tables/*.json 86.7 KiB 8 modules
    ./node_modules/statuses/codes.json 1.54 KiB [built] [code generated]
    ./node_modules/send/node_modules/mime/types.json 30.8 KiB [built] [code generated]
    ./node_modules/psl/data/rules.json 117 KiB [built] [code generated]
    ./node_modules/mime-db/db.json 139 KiB [built] [code generated]
modules by path ./src/ 10.9 KiB
  ./src/main/main.ts 7.18 KiB [built] [code generated]
  ./src/main/menu/menuTemplateInfobasket.js 2.54 KiB [built] [code generated]
  ./src/rxdb/infopiecesDb.js 1.17 KiB [built] [code generated]
20 modules

WARNING in ./node_modules/express/lib/view.js 81:13-25
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/express/lib/application.js 22:11-28
 @ ./node_modules/express/lib/express.js 18:12-36
 @ ./node_modules/express/index.js 11:0-41
 @ ./node_modules/rxdb/dist/es/plugins/server.js 3:0-30 126:12-19
 @ ./src/main/main.ts 36:19-49

WARNING in ./node_modules/rxdb/dist/es/plugins/server.js 17:19-45
Module not found: Error: Can't resolve 'express-pouchdb' in '/home/marco/webMatters/electronMatters/Raphy-Template
/node_modules/rxdb/dist/es/plugins'
 @ ./src/main/main.ts 36:19-49

2 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.31.0 compiled with 2 warnings in 11723 ms
Since version 8.4.0 the module 'express-pouchdb' is not longer delivered with RxDB.
You can install it with 'npm install express-pouchdb'
creating infopieces ..
start server
(node:16189) UnhandledPromiseRejectionWarning: TypeError: ExpressPouchDB is not a function
    at RxDatabaseBase.spawnServer [as server] (/home/marco/webMatters/electronMatters/Raphy-Template/node_modules
/rxdb/dist/lib/plugins/server.js:169:18)
    at App.<anonymous> (/home/marco/webMatters/electronMatters/Raphy-Template/dist/main/main.js:46:14)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `electron --trace-warnings ...` to show where the warning was created)
(node:16189) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing  
inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate  
the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org
/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16189) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections 
that are not handled will terminate the Node.js process with a non-zero exit code.
mainWindow loaded

如果我用 yarn add express-pouchdb@latest 安装 express-pouchdb:

├─ express-pouchdb@4.2.0

当我启动应用程序时出现此错误:

(base) marco@pc01:~/webMatters/electronMatters/Raphy-Template$ yarn start
yarn run v1.22.5
$ yarn run build && electron ./dist/main/main.js
$ npx webpack --config ./webpack.config.js
asset main.js 3.94 MiB [emitted] (name: main)
orphan modules 263 KiB [orphan] 138 modules
runtime modules 1.16 KiB 7 modules
modules by path ./node_modules/ 3.05 MiB
  javascript modules 2.69 MiB
    cacheable modules 2.68 MiB 509 modules
    ./node_modules/express-pouchdb/lib/ sync ^\.\/.*$ 2.51 KiB [built] [code generated]
    ./node_modules/express/lib/ sync 160 bytes [built] [code generated]
  json modules 376 KiB
    modules by path ./node_modules/iconv-lite/encodings/tables/*.json 86.7 KiB 8 modules
    4 modules
modules by path ./src/ 10.9 KiB
  ./src/main/main.ts 7.18 KiB [built] [code generated]
  ./src/main/menu/menuTemplateInfobasket.js 2.54 KiB [built] [code generated]
  ./src/rxdb/infopiecesDb.js 1.17 KiB [built] [code generated]
22 modules

WARNING in ./node_modules/express/lib/view.js 81:13-25
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/express/lib/application.js 22:11-28
 @ ./node_modules/express/lib/express.js 18:12-36
 @ ./node_modules/express/index.js 11:0-41
 @ ./node_modules/rxdb/dist/es/plugins/server.js 3:0-30 126:12-19
 @ ./src/main/main.ts 36:19-49

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in ./node_modules/express-pouchdb/lib/routes/root.js 3:13-37
Module not found: Error: Can't resolve '../../package' in '/home/marco/webMatters/electronMatters/Raphy-Template  
/node_modules/express-pouchdb/lib/routes'
resolve '../../package' in '/home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb/lib/routes'
   using description file: /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb  
/package.json (relative path: ./lib/routes)
    using description file: /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb 
/package.json (relative path: ./package)
      no extension
        /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb/package doesn't exist
      .jsx
        /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb/package.jsx doesn't exist
      .js
        /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb/package.js doesn't exist
      ts
        /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb/packagets doesn't exist
      as directory
        /home/marco/webMatters/electronMatters/Raphy-Template/node_modules/express-pouchdb/package doesn't exist
 @ ./node_modules/express-pouchdb/lib/ sync ^\.\/.*$ ./routes/root.js ./routes/root
 @ ./node_modules/express-pouchdb/lib/index.js 238:6-26
 @ ./node_modules/rxdb/dist/es/plugins/server.js 17:19-45
 @ ./src/main/main.ts 36:19-49

ERROR in ./node_modules/pouchdb-fauxton/www/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type,currently
no loaders are configured to process this file. See    
https://webpack.js.org/concepts#loaders
> <!--
| // Licensed under the Apache License,Version 2.0 (the "License"); 
you may not
| // use this file except in compliance with the License. You may 
obtain a copy of
 @ ./node_modules/express-pouchdb/lib/routes/fauxton.js 7:32-66
 @ ./node_modules/express-pouchdb/lib/ sync ^\.\/.*$ ./routes
/fauxton.js ./routes/fauxton
 @ ./node_modules/express-pouchdb/lib/index.js 238:6-26
 @ ./node_modules/rxdb/dist/es/plugins/server.js 17:19-45
 @ ./src/main/main.ts 36:19-49

webpack 5.31.0 compiled with 2 errors and 1 warning in 11729 ms

应用程序打不开....

O.S.:  Ubuntu 18.04.4 Desktop
node: v14.5.0
nvm: 0.34.0

我在这里发现了一个类似的问题:express-pouchdb relative module was not found 但那里给出的指示并没有解决我的问题

如何解决问题?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res