I am a massive fan of the brew package management system for macOS and use it on all of my Mac’s I typically just upgrade everything blindly and have never had an issue….. Until today…
I went to push some changes to this site and got the following error message
wrangler publish --env production
/usr/local/bin/node: bad option: --openssl-legacy-provider
Error: failed to execute `"/usr/local/bin/node" "--openssl-legacy-provider" "/Users/jameskilby/Library/Caches/.wrangler/wranglerjs-1.19.6" "--output-file=/var/folders/89/z9t99sg16h9cw3t86wp920jr0000gn/T/.wranglerjs_outputGBCY9" "--wasm-binding=WASM_MODULE" "--no-webpack-config=1" "--use-entry=/Users/jameskilby/jameskilbycouk/workers-site/index.js"`: exited with exit status: 9
A quick bit of digging and it turns out the error was due to a new version of node being used (Version 17)
The brew search command showed that I still had node16 installed
brew search node
==> Formulae
libbitcoin-node node ✔ node-sass node@12 node@16 ✔ nodebrew nodenv
llnode node-build node@10 node@14 node_exporter nodeenv ode
So I then removed the link to the generic node and forced the link to node@16
brew unlink node
brew link --overwrite node@16
Once this was done wrangler worked as expected and published my changes
rangler publish --env production
✨ Built successfully, built project size is 13 KiB.
🌀 Using namespace for Workers Site "__jameskilbycouk-production-workers_sites_assets"
✨ Success
🌀 Uploading site files
Certainly not a complex fix but hopefully handy for anyone playing with Wrangler on a Mac and using homebrew.