launchdarkly / node-client-sdk

LaunchDarkly Client-side SDK for Node.js
Other
9 stars 5 forks source link

module dependencies attempting to access 'fs' #10

Closed takotaco closed 4 years ago

takotaco commented 4 years ago

Describe the bug I'm getting this error:

ERROR in ./node_modules/graceful-fs/graceful-fs.js
    Module not found: Error: Can't resolve 'fs' in '/Users/me/dev/myapp/node_modules/graceful-fs'
     @ ./node_modules/graceful-fs/graceful-fs.js 1:9-22
     @ ./node_modules/node-localstorage/node_modules/write-file-atomic/index.js
     @ ./node_modules/node-localstorage/LocalStorage.js
     @ ./node_modules/launchdarkly-node-client-sdk/src/nodePlatform.js
     @ ./node_modules/launchdarkly-node-client-sdk/src/index.js
     @ multi babel-polyfill whatwg-fetch abortcontroller-polyfill blueimp-canvas-to-blob ./app/client.js webpack-hot-middleware/client?name=myapp&timeout=20000&reload=true&quiet=false&noInfo=false

    ERROR in ./node_modules/node-localstorage/LocalStorage.js
    Module not found: Error: Can't resolve 'fs' in '/Users/me/dev/myapp/node_modules/node-localstorage'
     @ ./node_modules/node-localstorage/LocalStorage.js 9:7-20
     @ ./node_modules/launchdarkly-node-client-sdk/src/nodePlatform.js
     @ ./node_modules/launchdarkly-node-client-sdk/src/index.js
     @ multi babel-polyfill whatwg-fetch abortcontroller-polyfill blueimp-canvas-to-blob ./app/client.js webpack-hot-middleware/client?name=myapp&timeout=20000&reload=true&quiet=false&noInfo=false

    ERROR in ./node_modules/winston/lib/winston/common.js
    Module not found: Error: Can't resolve 'fs' in '/Users/me/dev/myapp/node_modules/winston/lib/winston'
     @ ./node_modules/winston/lib/winston/common.js 12:9-22
     @ ./node_modules/winston/lib/winston/container.js
     @ ./node_modules/winston/lib/winston.js
     @ ./node_modules/launchdarkly-node-client-sdk/src/index.js
     @ multi babel-polyfill whatwg-fetch abortcontroller-polyfill blueimp-canvas-to-blob  ./app/client.js webpack-hot-middleware/client?name=myapp&timeout=20000&reload=true&quiet=false&noInfo=false

    ERROR in ./node_modules/winston/lib/winston/transports/file.js
    Module not found: Error: Can't resolve 'fs' in '/Users/me/dev/myapp/node_modules/winston/lib/winston/transports'
     @ ./node_modules/winston/lib/winston/transports/file.js 10:9-22
     @ ./node_modules/winston/lib/winston/transports.js
     @ ./node_modules/winston/lib/winston.js
     @ ./node_modules/launchdarkly-node-client-sdk/src/index.js
     @ multi babel-polyfill whatwg-fetch abortcontroller-polyfill blueimp-canvas-to-blob ./app/client.js webpack-hot-middleware/client?name=myapp&timeout=20000&reload=true&quiet=false&noInfo=false

I don't understand why it is trying to access the file system for a client-side web SDK. Help?

To reproduce

  1. Have an app complied with webpack.
  2. npm install launchdarkly-node-client-sdk@1.4.0 --save
  3. start node server which runs webpack to build bundle.js. webpack fails to compile.

Expected behavior No errors, especially not one related to being able to access fs, as this is a client side sdk.

Logs see above

SDK version "launchdarkly-node-client-sdk": "^1.4.0",

Language version, developer tools node, webpack, react/redux.

OS/platform MacOS

Additional context Add any other context about the problem here.

eli-darkly commented 4 years ago

I think this is just a misunderstanding of what "client-side" means in this context. It doesn't mean "in a web browser"— it means "in any context that is not server-side".

A web browser is one kind of client-side environment, but not the only kind. It sounds like you are writing front-end JavaScript code, so what you want to use is launchdarkly-js-client-sdk.

The purpose of launchdarkly-node-client-sdk is for client-side code that runs in Node.js. It differs from the server-side Node SDK, launchdarkly-node-server-sdk, in that it is meant to be deployed in some environment that belongs to an end user, rather than to the application maintainer, and that runs for one end user at a time rather than servicing requests from many users. For instance, it could be a command-line tool. It has nothing to do with web browsers, and if your code is not actually running in Node.js then you have no reason to use this.

eli-darkly commented 4 years ago

Reference guide for the browser JS SDK Reference guide for the client-side Node.js SDK Reference guide for the server-side Node.js SDK Client-side versus server-side SDKs

takotaco commented 4 years ago

Okay, I see. Sorry for the confusion. I'll look into the js SDK you linked, I must have missed that.