如何修复发生系统错误:uv_os_gethostname 在安装 vue cli 的节点中返回 ENOSYS

问题描述 投票:0回答:1

我也使用 Windows 7 并安装了

npm 9.2.0
nodev16.16.0
现在,当我尝试安装 vue cli 并尝试检查 vue cli 的版本时,出现以下错误消息,它是不可计数的

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Mara>vue v
node:os:68
      throw new ERR_SYSTEM_ERROR(ctx);
      ^

SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_os_gethostname retur
ned ENOSYS (function not implemented)
    at new Defaults (C:\node32\node_modules\@vue\cli\node_modules\@achrinza\node
-ipc\entities\Defaults.js:26:20)
    at new Parser (C:\node32\node_modules\@vue\cli\node_modules\@achrinza\node-i
pc\entities\EventParser.js:8:14)
    at Object.<anonymous> (C:\node32\node_modules\@vue\cli\node_modules\@achrinz
a\node-ipc\dao\client.js:11:19)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\node32\node_modules\@vue\cli\node_modules\@achrinz
a\node-ipc\services\IPC.js:4:14) {
  code: 'ERR_SYSTEM_ERROR',
  info: {
    errno: -4054,
    code: 'ENOSYS',
    message: 'function not implemented',
    syscall: 'uv_os_gethostname'
  },
  errno: [Getter/Setter],
  syscall: [Getter/Setter]
}

C:\Users\Mara>

然后我找到了以下解决方案来解决此问题https://github.com/nodemailer/nodemailer/issues/1410#issuecomment-1124005921但无法解决此问题。任何人都可以帮助我

node.js npm vuejs3 vue-cli
1个回答
0
投票

在某些情况下,可以通过在调用导致错误的包之前添加

hostname-patcher
库 (
npm -i hostname-patcher
) 来解决问题:

import 'hostname-patcher'; // import patch first
import os from 'os'; // then os
// or module using os module and causes your error
import { moduleUsingOS } from 'example';

// will output your real hostname if patch and if not
console.log(os.hostname());

出现此错误的原因是 NodeJS 开发人员从版本 14 开始决定删除 os.hostname 函数,并且在他们看来,为了删除单个函数,可以放弃对 Windows 7 的支持... 嗯...

有关该错误的更多详细信息:https://github.com/nodemailer/nodemailer/issues/1410
开发者评论:https://github.com/nodejs/help/issues/3878#issuecomment-1748877805

主机名补丁程序 github:https://github.com/Bellisario/hostname-patcher

此问题可能发生在内部包中,例如执行

npm login
命令时。我还不知道是否有办法解决这个问题......

如果您有机会(并且有愿望,这更困难)升级到新的 Windows,最好使用此选项。

© www.soinside.com 2019 - 2024. All rights reserved.