“Could not determine Node.js install directory” 在运行 npm install 时出现。

huangapple go评论156阅读模式
英文:

"Could not determine Node.js install directory" when running npm install

问题

在尝试运行npm install时,或者尝试通过任何终端安装任何Node相关的东西(比如nvm),甚至在Visual Studio Code中,我一直都遇到这个错误:

    err = this._handle.open(fd);
                       ^

Error: EISDIR: 对目录的非法操作,uv_pipe_open
    at new Socket (node:net:404:24)
    at createWritableStdioStream (node:internal/bootstrap/switches/is_main_thread:78:18)
    at process.getStdout [as stdout] (node:internal/bootstrap/switches/is_main_thread:148:12)
    at console.get (node:internal/console/constructor:210:42)
    at console.value (node:internal/console/constructor:338:50)
    at console.log (node:internal/console/constructor:377:61)
    at evalScript (node:internal/process/execution:90:5)
    at node:internal/main/eval_string:28:3 {
  errno: -4068,
  code: 'EISDIR',
  syscall: 'uv_pipe_open'
}

Node.js v18.13.0
node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: 找不到模块 'C:\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.13.0
无法确定Node.js安装目录

我已经多次重新安装了node.js、npm、WSL和Visual Studio Code,试图解决这个问题。我还按照建议的解决方案这里这里这里进行了尝试,但都没有成功。我还确保了将node和npm添加到了我的环境变量PATH中。到目前为止,我尝试解决这个问题还没有取得成功。我还能尝试什么?我可能遗漏了哪些步骤吗?

英文:

When attempting to run npm install, or when attempting to install anything through Node (like nvm) through any terminal (or in Visual Studio Code itself), I consistently get this error:

node:net:404
    err = this._handle.open(fd);
                       ^

Error: EISDIR: illegal operation on a directory, uv_pipe_open
    at new Socket (node:net:404:24)
    at createWritableStdioStream (node:internal/bootstrap/switches/is_main_thread:78:18)
    at process.getStdout [as stdout] (node:internal/bootstrap/switches/is_main_thread:148:12)
    at console.get (node:internal/console/constructor:210:42)
    at console.value (node:internal/console/constructor:338:50)
    at console.log (node:internal/console/constructor:377:61)
    at evalScript (node:internal/process/execution:90:5)
    at node:internal/main/eval_string:28:3 {
  errno: -4068,
  code: 'EISDIR',
  syscall: 'uv_pipe_open'
}

Node.js v18.13.0
node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: Cannot find module 'C:\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.13.0
Could not determine Node.js install directory

I have reinstalled node.js, npm, WSL, and Visual Studio Code multiple times attempting to fix the issue. I have also followed the suggested solutions here, here, and here to no avail. I have ensured that node and npm are added to my PATH as well in the environment variables. So far I've had no luck attempting to fix this solution. What else can I try? Are there any steps I could be missing?

答案1

得分: 0

我认为问题是由于Ubuntu本身安装损坏引起的,而不是Node或WSL。重新安装整个Ubuntu似乎解决了问题。

英文:

I believe the issue was due to a corrupt installation of ubuntu itself, not node or WSL. Reinstalling ubuntu as a whole seemed to do the trick.

huangapple
  • 本文由 发表于 2023年1月11日 04:19:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75075388.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定