esbuild failure: No loader is configured for ".node" files
I just added a Node action and tried to deploy it to my dev environment, and observed the following error:
I'm guessing this has something to do with the
ssh2-sftp-client
package, which I haven't used before and which is a dependency of this particular action.7 Replies
bump
Convex Node.js actions don't support libraries which require compiling C code to install, in this case cpu-features.
We'd like to, we have ideas for this: install npm packages in the runtime environment instead of bundling them.
Reading the docs for ssh2, the library requiring cpu-features, it looks like it's supposed to be optional. https://www.npmjs.com/package/ssh2
npm
ssh2
SSH2 client and server modules written in pure JavaScript for node.js. Latest version: 1.14.0, last published: 7 days ago. Start using ssh2 in your project by running
npm i ssh2
. There are 1327 other projects in the npm registry using ssh2.Ah I see, it's not just cpu-features here but also ssh2 needing sshcrypto.node. Looks like ssh2 can't be used with Convex Node.js actions then, at least for now.
Does Convex's native runtime support such libraries?
No, there's also no compiled C code allowed in the Convex JavaScript runtime. Node.js actions may support this in the future, but the Convex runtime won't unless these are compiled to WebAssembly.
UPDATE: We have released a new beta feature in convex 1.4 (https://news.convex.dev/announcing-convex-1-4/) that will allow us to skip bundling and install the packages on the server. We believe this will likely get ssh2 working. More details on how to use the feature https://docs.convex.dev/functions/bundling?ref=news.convex.dev#external-packages.
Convex News
Announcing Convex 1.4
Convex 1.4 introduces a new option to install packages used in your Node action environment on the server, a variety of logging improvements, a new option to pause deployments, a new npm create convex command and more!
External packages in Node.js
Before 1.4, several NPM dependencies were
Bundling | Convex Developer Hub
Bundling is the process of gathering, optimizing and transpiling the JS/TS