Manomite
Manomite13mo ago

Error using npm convex dev

I keep getting this error when using the command... [ERROR] Could not resolve "stream" node_modules/jws/lib/sign-stream.js:5:21: 5 │ var Stream = require('stream'); ╵ ~~~~ The package "stream" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. Am using node packages. Please what should I do...
4 Replies
sshader
sshader13mo ago
This sounds like you want an action with the "use node" directive at the top (https://docs.convex.dev/functions/runtimes#nodejs-runtime,) wherever you're using this library.
Runtimes | Convex Developer Hub
Convex functions can run in two runtimes:
Manomite
ManomiteOP13mo ago
Yes... I have used "use node" at the top of te file but from the documentation i can see that jsonwebtoken node package is not listed among the supported API. jsonwebtoken has lots of dynamic imports (via import/require calls) from other libraries which convex find it difficult to find... This is what has been giving the issue Although i have internalMutation also inside the action file... Or is this why the "use node" is not working? From the documentation, it says; The default runtime supports most npm libraries that work in the browser, Deno, and Cloudflare workers. If your library isn't supported, you can use an action with the Node.js runtime, or reach out in Discord. We are improving support all the time. I have used an action but still not working...
sshader
sshader13mo ago
Hmm, just to check, could you run npx convex dev --verbose? It'll print out a list of bundled files and which ones are using Convex's runtime vs. Node.js, so we can check that the files importing that node module appear under "Node.js runtime modules:". (feel free to paste output here or DM me if you'd like an extra set of eyes) Also mutations and queries cannot be defined in files with the the "use node" directive, so I'd move your internalMutation to a different file.
Manomite
ManomiteOP13mo ago
Okay I will do this tomorrow and send in the screenshots... Thanks...

Did you find this page helpful?