关于在Android容器内运行Linux启动Docusarus出现“Unknown system error 13”问题的解决方法
· 阅读需 2 分钟
前些日子喜欢使用米pad5pro运行linux容器进行一些轻开发。不过我在使用Linux容器进行Docusarus的博客编写的时候,发现直接使用npm start
没有办法正常启动预览:
> my-website@0.0.0 start
> docusaurus start
[INFO] Starting the development server...
node:os:68
throw new ERR_SYSTEM_ERROR(ctx);
^
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_interface_addresses returned Unknown system error 13 (Unknown system error 13)
at Object.networkInterfaces (node:os:277:16)
at address.interface (/root/DanielToyama.github.io/node_modules/address/lib/address.js:71:23)
at address.ip (/root/DanielToyama.github.io/node_modules/address/lib/address.js:111:22)
at /root/DanielToyama.github.io/node_modules/detect-port/lib/detect-port.js:88:32
at Server.<anonymous> (/root/DanielToyama.github.io/node_modules/detect-port/lib/detect-port.js:118:12)
at Object.onceWrapper (node:events:632:28)
at Server.emit (node:events:518:28)
at emitListeningNT (node:net:1906:10)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'ERR_SYSTEM_ERROR',
info: {
errno: 13,
code: 'Unknown system error 13',
message: 'Unknown system error 13',
syscall: 'uv_interface_addresses'
},
errno: [Getter/Setter],
syscall: [Getter/Setter]
}
Node.js v20.11.1
究其原因,其实是因为容器proot环境的docusarus没有使用0.0.0.0的ip进行创建服务器的权限。解决办法也很简单,使用127.0.0.1进行启动就可以了:
使用启动指令npm run start -- --host 127.0.0.1
就可以正常启动端口开始愉快的玩耍了
当然你也可以把这个东西写进package.json的启动指令,以后就可以进行快速调用:
/package.json
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
// 这里添加了指令local
"local": "docusaurus start --host 127.0.0.1",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids"
},
这样使用指令npm run local
就可以从127.0.0.1启动了