用docker方式安装的node-red,一直装不了node-red-contrib-home-assistant-websocket 0.46.2,提示如下错误:
2022-11-11T12:47:21.281Z 安装 : node-red-contrib-home-assistant-websocket 0.46.2
2022-11-11T12:47:21.489Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict [email protected]
2022-11-11T12:47:32.085Z [err] npm
2022-11-11T12:47:32.086Z [err] notice created a lockfile as package-lock.json. You should commit this file.
2022-11-11T12:47:32.091Z [err] npm
2022-11-11T12:47:32.091Z [err] WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
2022-11-11T12:47:32.091Z [err] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected] : wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2022-11-11T12:47:32.091Z [err]
2022-11-11T12:47:32.093Z [out] + [email protected]
2022-11-11T12:47:32.093Z [out] added 236 packages from 336 contributors in 10.245s
2022-11-11T12:47:32.106Z rc=0
复制代码
看意思是fsevents这个依赖装不上,然而linux并不需要这个依赖,据说是npm 8的一个bug。。。
试了N遍终于找到解决办法,记录如下:
#进入docker容器
docker exec -it nodered /bin/bash
#设置腾讯源(这步很关键,貌似阿里源就不行)
npm config set registry http://mirrors.cloud.tencent.com/npm/
#强制安装fsevents
npm i -f [email protected]
#手动安装[email protected]
npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict [email protected]
#修复一下
npm audit fix -f
#退出容器
exit
#重启容器,搞掂!
docker restart nodered
复制代码
如图: