Closed dandv closed 6 years ago
I think you mean to use the browser version: https://node-influx.github.io/manual/usage.html#browser-setup
The error says it's expecting process
, which means it's a Node.js library. This is 100% something you don't want to be shimmed on the browser. CRA allows this mistake.
I've never used this library, so if it still complains about wanting process
, here's how you enable it:
// preact.config.js
module.exports = config => {
config.node.process = true
}
I've tried that preact.config.js setting, and now I get "Buffer is not defined".
Here's a repo showing that influx can be used in the browser apparently without any shimming. It's reduced to the minimum from a project in which I am able to actually use Influx in the browser to retrieve data from a database.
Okay. You can do the same with Buffer
. You'll see all the node shims we disable in that link I provided.
Didn't realize that webpack shimmed process and Buffer by default. Thanks!
No problem!
Bug report
What is the current behaviour?
Importing the influx package in
src/components/app.js
causes this error in the browser:Influx is not a React package, yet it seems impossible to use influx in preact apps. It can be imported without issue in a React app.
If the current behaviour is a bug, please provide the steps to reproduce.
What is the expected behaviour?
This works in React:
Please mention other relevant information.