[英]PouchDB and electron (windows env)
While playing with Electron (under Windows) I tried to use PouchDB. 在玩Electron时(在Windows下),我尝试使用PouchDB。 Unfortunately it does not seem to work for me. 不幸的是,它似乎对我不起作用。
In my case package.json looks like this: 就我而言,package.json看起来像这样:
"devDependencies": {
"electron": "^1.4.12",
"electron-rebuild": "^1.4.0"
},
"dependencies": {
...
"electron-reload": "^0.2.0",
"pouchdb": "*",
"pouchdb-adapter-node-websql": "*",
"pouchdb-find": "*",
...
}
and js code itself: 和js代码本身:
var pouch = require('pouchdb');
var db = new pouch('mydb-websql');
console.log(db)
Results are similar to following: 结果类似于以下内容:
> PouchDB$5 { __opts: { name: 'mydb-websql', adapter: 'leveldb' },
> auto_compaction: undefined, prefix: '_pouch_', name:
> 'mydb-websql', _adapter: 'leveldb', domain: null, _events: {},
> _eventsCount: 0, _maxListeners: undefined, taskqueue: TaskQueue$1 {
> isReady: false,
> failed:
> Error: Error: Could not locate the bindings file. Tried:
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \build\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \build\Debug\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \build\Release\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \out\Debug\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \Debug\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \out\Release\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \Release\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \build\default\leveldown.node
> Ôćĺ c:\learning\electron\node_modules\pouchdb\node_modules\leveldown
> \compiled\6.5.0\win32\x64\leveldown.node: unable to import leveldown
> at requireLeveldown (c:\learning\electron\node_modules\pouchdb\li b\index.js:5173:12)
> at PouchDB$5.LevelDownPouch (c:\learning\electron\node_modules\po uchdb\lib\index.js:5373:17)
> at new PouchDB$5 (c:\learning\electron\node_modules\pouchdb\lib\i ndex.js:2753:36)
> at Object.<anonymous> (c:\learning\electron\main.js:6:10)
> at Module._compile (module.js:556:32)
> at Object.Module._extensions..js (module.js:565:10)
> at Module.load (module.js:473:32)
> at tryModuleLoad (module.js:432:12)
> at Function.Module._load (module.js:424:3)
> at loadApplicationPackage (C:\Users\adam\AppData\Roaming\npm\node_modu
> les\electron\dist\resources\default_app.asar\main.js:280:12),
> queue: [] }, adapter: 'leveldb' }
When I use websql adapter results are even I would say worse: 当我使用websql适配器时,结果甚至会更糟:
App threw an error during load
Error: Invalid Adapter: websql
at new PouchDB$5 (c:\learning\electron\node_modules\pouchdb\lib\index.j
s:2745:11)
at Object.<anonymous> (c:\learning\electron\main.js:6:10)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at loadApplicationPackage (C:\Users\adam\AppData\Roaming\npm\node_modules\el
ectron\dist\resources\default_app.asar\main.js:280:12)
at Object.<anonymous> (C:\Users\adam\AppData\Roaming\npm\node_modules\electr
on\dist\resources\default_app.asar\main.js:322:5)
at Module._compile (module.js:556:32)
I must admit that I tried to rebuild everything, i tried all adapters with no good outcome. 我必须承认,我尝试重建所有内容,尝试了所有适配器,但均未取得良好结果。 I tried to install sqlite3 additionally and failed again. 我尝试另外安装sqlite3,但再次失败。
Do you perhaps have any other ideas what can go wrong with it or where I may expect my mistake? 您是否还有其他想法可能会出什么问题或在哪里会预料到我的错误?
I tried the same code under linux with and without adapter with failure. 我在带有和不带有适配器的Linux下尝试了相同的代码,但均失败了。 I think it does not depend on os 我认为这不依赖于操作系统
Ok, I found the issue. 好的,我发现了问题。 The problem was OS related and it all was around recompiling sqlite3. 问题与操作系统有关,而所有问题都与重新编译sqlite3有关。 Actually i needed to add windows toolkit and set path to python later (i read it from errors). 实际上,我需要添加Windows工具箱并在以后设置python的路径(我从错误中读取了它)。 I figure it out after checking that under linux everything went smoothly. 在检查完Linux下一切运行顺利之后,我弄清楚了。
Perhaps it would be safer to change my OS to linux but actually i need to develop for windows. 将操作系统更改为linux也许会更安全,但实际上我需要为Windows开发。 I need to find balanced way ;) 我需要找到平衡的方法;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.