简体   繁体   English

在 VSCode 中运行“npm install”时遇到问题。 抛出`npm ERR! 每次编码 ENOENT`

[英]Having trouble running `npm install` in VSCode. Throws `npm ERR! code ENOENT` each time

I am currently experiencing problems when running 'npm install' in my VSCode.我目前在我的 VSCode 中运行“npm install”时遇到问题。 I am running a laravel project with Vue.js.我正在使用 Vue.js 运行 laravel 项目。 In the path that holds my package.json, I first installed node from the browser and now I' trying to run npm install in order to get the correct node_modules folder set up to run my application.在包含我的 package.json 的路径中,我首先从浏览器安装了节点,现在我试图运行 npm 安装以运行我的应用程序设置。 I have tried the following solutions, but none have been able to resolve the problem.我尝试了以下解决方案,但没有一个能够解决问题。

I ran these commands:我运行了这些命令:

npm install laravel-mix --save-dev
Npm install
Npm install && npm run dev
npm ci

I have also tried following this: npm install error from the terminal as well as double checking which directory package.json lives in.我也尝试过以下操作: npm 从终端安装错误,并仔细检查 package.json 所在的目录。

This is the output of npm version这是npm version的output

  npm: '8.15.0',
  node: '16.17.0',
  v8: '9.4.146.26-node.22',
  uv: '1.43.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '93',
  nghttp2: '1.47.0',
  napi: '8',
  llhttp: '6.0.7',
  openssl: '1.1.1q+quic',
  cldr: '41.0',
  icu: '71.1',
  tz: '2022a',
  unicode: '14.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

This is the error that I get when running npm install这是我在运行npm install时遇到的错误

npm ERR! code ENOENT
npm ERR! syscall spawn pwsh
npm ERR! path /Users/node_modules/deasync
npm ERR! errno -2
npm ERR! enoent spawn pwsh ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

I have tried to remove my project and re-clone it from git, as well as completely removing node from my computer and reinstalling it.我试图删除我的项目并从 git 重新克隆它,以及从我的计算机中完全删除节点并重新安装它。 Lastly, I installed avn and nvm to try and control the different node versions and make sure everything is compatible.最后,我安装了 avn 和 nvm 来尝试控制不同的节点版本并确保一切都兼容。 I have also tried disabling any anti-virus software that I have running but none of those have worked either.我还尝试禁用我正在运行的任何防病毒软件,但这些都没有工作。

for anyone experiencing my problem, I ended up doing 3 things at once so I'm not completely sure which of these was the eventual solution:对于任何遇到我的问题的人,我最终一次做了 3 件事,所以我不完全确定其中哪一个是最终的解决方案:

  1. I disabled my firewall (I was running Sophos)我禁用了我的防火墙(我正在运行 Sophos)

  2. I reset my permissions for the folder I was working in by first doing cd.. from the repo my project rested in and then running chown -R 502:20 [replace with directory where repo exists]我重置了我正在工作的文件夹的权限,首先从我的项目所在的仓库中执行cd..然后运行chown -R 502:20 [replace with directory where repo exists]

  3. and finally, I installed Power shell using brew install --cask powershell最后,我使用brew install --cask powershell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM