Ubuntu20.04运行wiki.js服务器出错问题解决方法
错误代码:
root@xxx:/home/xxxxx/wiki# node server
Loading configuration from /home/xxxxx/wiki/config.yml... OK
2022-10-23T05:00:25.563Z [MASTER] info: =======================================
2022-10-23T05:00:25.564Z [MASTER] info: = Wiki.js 2.5.289 =====================
2022-10-23T05:00:25.564Z [MASTER] info: =======================================
2022-10-23T05:00:25.565Z [MASTER] info: Initializing...
2022-10-23T05:00:25.906Z [MASTER] info: Using database driver pg for postgres [ OK ]
2022-10-23T05:00:25.907Z [MASTER] info: Connecting to database...
2022-10-23T05:00:25.945Z [MASTER] info: Database Connection Successful [ OK ]
2022-10-23T05:00:26.276Z [MASTER] warn: Mail is not setup! Please set the configuration in the administration area!
2022-10-23T05:00:26.339Z [MASTER] info: Loading GraphQL Schema...
2022-10-23T05:00:26.703Z [MASTER] error: Package subpath './public/extractFiles' is not defined by "exports" in /home/xxxxx/wiki/node_modules/extract-files/package.json
解决方法:
这里参考overflow上老外的方法:
Possible Solutions:
- Update extract-files package to latest
- Use Node 16.x
我用的是第二种,把nodejs版本更新到16.x即可。
这里用nvm安装node版本是最好:
安装步骤参考地址:https://nextgentips.com/2021/12/26/how-to-install-node-js-17-on-ubuntu-20-04/
到$ nvm install v17.3.0这步,记得把版本17.x改成16.x即可,我这里改的是v16.17.0。
出错原因:
Node版本问题,可能太旧了也可能太新了,我的是太新了。。。(之前手欠安装了node v19.0.0版本,但是又尝试了各种方法卸载不干净nodejs,遂每次node启动服务器都要重新nvm安装一下node老版本,这里建议16.x)
再补充一下加速nvm的国内nodejs镜像,是淘宝的:NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
每次运行nvm安装命令之前输入这个,下载速度就快多了。