node17+版本兼容性报错digital envelope routines::unsupported
本地node升级成18.x版本后,启动原先的项目会出现报错:digital envelope routines::unsupported
通过查找原因,这是由于node 17的bug,解决方法如下:
修改package.js,在相关构建命令之前加入set NODE_OPTIONS=--openssl-legacy-provider
"scripts": { "start": "set NODE_OPTIONS=--openssl-legacy-provider && concurrently --kill-others \"nodemon\" \"npm run start:client\"", "start:server": "set NODE_OPTIONS=--openssl-legacy-provider && node ./bin/www", "start:client": "set NODE_OPTIONS=--openssl-legacy-provider && npm run start --prefix client", "build": "set NODE_OPTIONS=--openssl-legacy-provider && npm run build --prefix client", "build:run": "set NODE_OPTIONS=--openssl-legacy-provider && npm run build && npm run start:server", "dev": "set NODE_OPTIONS=--openssl-legacy-provider && set NODE_ENV=dev && nodemon" },
重新启动项目就好了。