support building cocalc using nodejs version 18
The build currently fails building the frontend using webpack. We hit exactly this bug:
https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported
There's a workaround there to add a command line flag to node.
The first big issue I hit with trying to use node v18 to build CoCalc is that they removed the md4 crypto algorithm, which breaks webpack. Amusingly, the solution webpack has for the problem is reintroduce md4 back to webpack by getting some AssemblyScript version of it! https://github.com/webpack/webpack/pull/14584. It's quite cool. Once compiled, the actual code is just a tiny little base64 string burried in the minified js that gets loaded on the fly. Unfortunately, the exact same bug is also in the file-loader webpack plugin, which got deprecated, so I also need to rewrite cocalc to not use that. But that's a good thing to do anyways.
So next step -- switch from using file-loader to using the asset modules, as suggested here: https://github.com/webpack-contrib/file-loader#readme
I used asset modules for my python-wasm examples here, and they are easy: https://github.com/sagemathinc/python-wasm/blob/main/packages/webpack/webpack.config.js#L35
Now everything builds. However, running locally on MacOS (no virtualization or linux), the hub is not connecting to projects, though the project is running and accepting connections.
Confirmed -- switching back to node 16 and rebuilding immediately fixed the problem.
Another update. I just did a 100% clean build from scratch on a clean Ubuntu 22.04 image (on aarch64 linux) with node 18 and Postgres 14, and everything worked perfectly, including connecting to projects. So maybe that's not a problem, and it's just caused by stuff left laying around in the above case.
obviously fixed long ago