pusher / chatkit-server-node

Node.js SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
16 stars 9 forks source link

Chatkit-Server not working (fs dependency missing) #50

Closed ZeroPie closed 4 years ago

ZeroPie commented 5 years ago

What?

Chatkit-Server not working on a Gatsby Build with: "@pusher/chatkit-client": "^1.5.0", "@pusher/chatkit-server": "^1.3.0"

import Chatkit from '@pusher/chatkit-server'

const chatkit = new Chatkit({ instanceLocator: instanceLocator, key: secretKey })

 ERROR  Failed to compile with 2 errors                                                                                                 10:00:48 PM
⠀
This dependency was not found:
⠀
* fs in ./node_modules/@pusher/chatkit-server/node_modules/got/source/utils/get-body-size.js, ./node_modules/request/lib/har.js
⠀
To install it, you can run: npm install --save fs
error ✖ 「wdm」:
ERROR in ./node_modules/@pusher/chatkit-server/node_modules/got/source/utils/get-body-size.js
Module not found: Error: Can't resolve 'fs' in
'/Users/pie/Desktop/gatsby/wunschcoach-ssr/node_modules/@pusher/chatkit-server/node_modules/got/source/utils'
 @ ./node_modules/@pusher/chatkit-server/node_modules/got/source/utils/get-body-size.js 2:11-24
 @ ./node_modules/@pusher/chatkit-server/node_modules/got/source/request-as-event-emitter.js
 @ ./node_modules/@pusher/chatkit-server/node_modules/got/source/as-stream.js
 @ ./node_modules/@pusher/chatkit-server/node_modules/got/source/create.js
 @ ./node_modules/@pusher/chatkit-server/node_modules/got/source/index.js
 @ ./node_modules/@pusher/chatkit-server/target/src/chatkit.js
 @ ./node_modules/@pusher/chatkit-server/target/src/index.js
 @ ./src/chat/chatkit/chatkit.js
 @ ./src/components/molecules/ListItem/ListItemPendingContact.js
 @ ./src/components/pages/Private/ContactsPage.js
 @ ./src/gatsby/pages/app.js
 @ ./.cache/sync-requires.js
 @ ./.cache/app.js
 @ multi ./node_modules/event-source-polyfill/src/eventsource.js (webpack)-hot-middleware/client.js?path=/__webpack_hmr&reload=true&overlay=false
./.cache/app

ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '/Users/pie/Desktop/gatsby/wunschcoach-ssr/node_modules/request/lib'
 @ ./node_modules/request/lib/har.js 3:9-22
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./node_modules/@pusher/platform-node/target/base_client.js
 @ ./node_modules/@pusher/platform-node/target/index.js
 @ ./node_modules/@pusher/chatkit-server/target/src/index.js
 @ ./src/chat/chatkit/chatkit.js
 @ ./src/components/molecules/ListItem/ListItemPendingContact.js
 @ ./src/components/pages/Private/ContactsPage.js
 @ ./src/gatsby/pages/app.js
 @ ./.cache/sync-requires.js
info ℹ 「wdm」: Failed to compile.

Suggested improvements

callum-oakley commented 5 years ago

I'm not familiar with Gatsby so I may be misunderstanding, but where is the server component running? Chatkit server needs to be run in a node environment (and fs is a node builtin).

see https://github.com/gatsbyjs/gatsby/issues/564

minaorangina commented 4 years ago

Closing as stale. If this is still an issue please contact us at support@pusher.com where someone will be able to give dedicated help.