Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: installation and running node based pouchdb-server fails (leveldown and pouchdb node errors) #62

Closed
algorist-mechanism opened this issue May 22, 2021 · 2 comments

Comments

@algorist-mechanism
Copy link


name: Installation and running pouchdb-server error
about:
title: ''
labels: 'leveldown', "pouchdb"
assignees: ''


Describe the bug
Unable to install and run node based pouchdb-server. https://github.com/pouchdb/pouchdb-server

  1. Installing leveldown fails.
  2. Running example pouchdb-server index.js fails.

Link to the blitz that caused the error
https://stackblitz.com/edit/node-kx3sgx

To Reproduce
Steps to reproduce the behavior:
Follow steps from https://github.com/pouchdb/pouchdb-server#usage-1.

  1. npm install express-pouchdb pouchdb express

yields

warn preInstall No description field
warn preInstall No repository field
warn preInstall No license field
┌ [1/3] 🔍  Resolving dependencies
└ Completed in 5.328s
┌ [2/3] 🚚  Fetching dependencies
└ Completed in 0.356s
┌ [3/3] 🔗  Linking dependencies
└ Completed in 0.357s
info security We found `install` scripts which turbo skips for
security reasons. For more information see
https://turbo.sh/install-scripts.
└─ leveldown@5.6.0

success Saved lockfile "package-lock.json"
success Updated "package.json"

success Install finished in 6.119s 
  1. Replace index.js (from https://github.com/pouchdb/pouchdb-server#usage-1.) with
var PouchDB = require('pouchdb');
var express = require('express');
var app = express();
app.use('/db', require('express-pouchdb')(PouchDB));
app.listen(3000);
  1. run using node index.js yields error:
TypeError: Cannot read property 'arm_version' of undefined
    at Object.eval (/projects/node-kx3sgx/node_modules/node-gyp-build/index.js:14:90)
    at Object.function (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:11:19819)
    at Module._compile (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:6:187549)
    at Object.Module._extensions..js (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:6:187908)
    at Module.load (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:6:185988)
    at Function.Module._load (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:6:183564)
    at Module.require (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:6:186304)
    at i (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:6:484674)
    at _0x1e5cfd (https://node-kx3sgx.jw.staticblitz.com/blitz.7286dbe8d47d3473cde7be488b7d048fb59b05f2.js:11:19724)
    at Object.eval (/projects/node-kx3sgx/node_modules/leveldown/binding.js:1:79)

Expected behavior
A clear and concise description of what you expected to happen.

  1. Able to install pouchdb-server
  2. Able to run example index.js

Version of webcontainer
Hash: 7286dbe8d47d3473cde7be488b7d048fb59b05f2

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Browser name = Chrome
Full version = 90.0.4430.212
Major version = 90
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
performance.memory = {
totalJSHeapSize: 51211101,
usedJSHeapSize: 47415453,
jsHeapSizeLimit: 2172649472
}

Additional context
Not sure what storage type is available in the stackblitz webcontainer. Using one of the other adapters from https://pouchdb.com/adapters.html may work, instead of the node version which using leveldown storage.

Does stackblitz web container require a web assembly? leveldown is not available as a web assembly as far as I know Level/community#63

@algorist-mechanism algorist-mechanism changed the title BUG: BUG: nstallation and running pouchdb-server error (leveldown and pouchdb node errors) May 22, 2021
@algorist-mechanism algorist-mechanism changed the title BUG: nstallation and running pouchdb-server error (leveldown and pouchdb node errors) BUG: installation and running node based pouchdb-server fails (leveldown and pouchdb node errors) May 22, 2021
@KwintenP
Copy link
Contributor

It seems like it's trying to compile a native addon using node-gyp-build. Since on stackblitz everything is running in the browser's context, this will not work. Using native addons cannot be supported and need a wasm based replacement.

I'm not sure what native module it is actually trying to run. We do have an initiative to port over existing native addons to wasm and replace them at install time using our own npm client.

@algorist-mechanism
Copy link
Author

It's trying to install leveldown. (npm https://www.npmjs.com/package/leveldown and repo https://github.com/Level/leveldown)
It tries to install a prebuilt version first based on the platform, then run node-gyp-build to build locally if it cannot find a prebuilt.
There's a work around for pouchdb-server (It can use indexedDB, webSQL with sqlite3, localStorage, or in memory). The default is leveldown however. I wanted to see if it would work and document it for others if it didn't.

@jrvidal jrvidal closed this as completed Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants