Closed davidgeary closed 3 years ago
I think this is as a result of using Nano in a browser, rather than server-side from within a Node.js project. So the browser doesn't know what the http
, https
and stream
modules are.
I'm no expert in transpiling Node.js modules for browser use.
If I were writing to CouchDB from within the browser, I'd use Fetch API - not quite as easy as Nano, but definitely not unmanageable - and you get to learn the CouchDB API too! :)
That makes sense - thanks @glynnbird.
As it happens, I did end up writing directly against the CouchDB API (using Angular's HttpClient
service), so yes, I've now learnt the API which is no bad thing.
Expected Behavior
I expect the project to build without errors.
Current Behavior
I'm writing an Angular project to which I've added nano (as per https://github.com/apache/couchdb-nano#typescript). But as soon as I include a call such as:
I get errors when building the project about missing modules, eg:
(The actual error then lists all of the places it has checked for the existence of the missing module, which I'm omitting for brevity.)
The same error message is repeated for the
https
andstream
modules.Steps to Reproduce
Stackblitz
I've created a sample of this on Stackblitz. Stackblitz doesn't show the full underlying console error message unfortunately, but does show the message:
Locally
If you have the Angular CLI installed, this can be seen in a minimal sample:
Create a new Angular app and then install nano:
Edit
tsconfig.json
to include"allowSyntheticDefaultImports": true
undercompilerOptions
.Edit
app.component.ts
to:Then build the project with
ng build
Your Environment