matrix-js-sdk: TypeError: this.opts.request is not a function when running client in Node.js; reopen issue #1191
I would like to reopen the issue #1191 since there is a similar error.
I’ve installed matrix-sdk-js
using Node.js v16.15.0
and initiated client as per example. Received TypeError: this.opts.request is not a function
. Also tried with nodejs v12, import
or require
of SDK, using async ... await
function, but the same issue.
any ideas?
_Originally posted by @jt0in3e in https://github.com/matrix-org/matrix-js-sdk/issues/1191#issuecomment-1141020280_
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 38 (12 by maintainers)
Commits related to this issue
- Merge tag 'v18.1.0' into sc * Convert `getLocalAliases` to a stable API call ([\#2402](https://github.com/matrix-org/matrix-js-sdk/pull/2402)). * Fix request, crypto, and bs58 imports ([\#2414](https... — committed to SchildiChat/matrix-js-sdk by su-ex 2 years ago
- Issue 5716 - bump matrix-js-sdk from 15.6.0 to 20.0.2 with workaround for github.com/matrix-org/matrix-js-sdk/issues/2415 — committed to taskcluster/taskcluster by petemoore 2 years ago
- Merge tag 'v21.0.0' into sc * Changes the `uploadContent` API, kills off `request` and `browser-request` in favour of `fetch`, removed callback support on a lot of the methods, adds a lot of tests. (... — committed to SchildiChat/matrix-js-sdk by su-ex 2 years ago
You can workaround it using
any update on this issue please ? this seems really blocking: usage of the JS SDK is blocked by this error .
But you’re still using the requests package, which doesn’t really help the rest of things out. This package has been deprecated for about 2 years already - this sdk really needs to move away from it altogether.
Hi, I had the same issue.
Setting ICreateClientOpts.request did the trick for me.
` const request = require(“request”);
// …
const client = sdk.createClient({ baseUrl: ‘https://matrix.org’, request: request })
// … `
accidentally clicked on “close with comment” o_0
I can’t use the SDK at the moment because of this - this needs to be top priority
It was not clear whether you’re in ts or js? Anyway, using the responses from this post I am able to get this working on node v16.15.0
test.js
produces
I just ran into this same error