在 vs code 中执行任何 npm 命令时出错

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

当我运行任何 npm 命令时,我都会得到这个,我所在的文件夹或项目并不重要,这一切都是从我尝试安装 React-draggable 时开始的。我遇到了很多错误,并且没有重新启动,重新安装似乎有帮助,所以我不知道还能做什么。我还在 Windows 高级配置文件设置中将系统 32 添加到我的环境中,但仍然没有任何结果。这是我遇到的 2 个错误:

这个在尝试启动反应应用程序时,在尝试添加可拖动的东西之前工作正常,但现在我得到了这个:

PS C:\Users\lewis\react> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\lewis\react\package.json
npm ERR! errno -4058
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Users\lewis\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in: C:\Users\lewis\AppData\Local\npm-cache\_logs\2024-04-14T20_47_31_482Z-debug-0.log
PS C:\Users\lewis\react> 

以及在 vscode 中使用

>create react app
时的这个:

Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:284:19)
    at onErrorNT (node:internal/child_process:477:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

这是当尝试使用终端而不是扩展创建一个新的 React 应用程序时:

C:\Users\lewis\REACT PLZ WORK>npm install -g create-react-app
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

changed 66 packages in 8s

4 packages are looking for funding
  run `npm fund` for details

C:\Users\lewis\REACT PLZ WORK>
C:\Users\lewis\REACT PLZ WORK>npm fund
REACT PLZ WORK


C:\Users\lewis\REACT PLZ WORK>

我有一种感觉,这些是有某种联系的,但我不知道如何解决它,我已经尝试了好几天了。

感谢任何提供帮助的人!!

我尝试重新安装node.js,但在打开powershell时出现此错误,即使在让它安装chocolatey本身(完全删除它并让安装程序执行此操作)并尝试手动更新它但它已经是最新版本后我还是得到了它。

ARNING: 'choco' was found at 'C:\ProgramData\chocolatey\bin\choco.exe'.
WARNING: An existing Chocolatey installation was detected. Installation will not continue. This script will not
overwrite existing installations.
If there is no Chocolatey installation at 'C:\ProgramData\chocolatey', delete the folder and attempt the installation
again.

Please use choco upgrade chocolatey to handle upgrades of Chocolatey itself.
If the existing installation is not functional or a prior installation did not complete, follow these steps:
 - Backup the files at the path listed above so you can restore your previous installation if needed.
 - Remove the existing installation manually.
 - Rerun this installation script.
 - Reinstall any packages previously installed, if needed (refer to the lib folder in the backup).

Once installation is completed, the backup folder is no longer needed and can be deleted.
Chocolatey v2.2.2
Upgrading the following packages:
python;visualstudio2019-workload-vctools
By upgrading, you accept licenses for the packages.
python v3.12.3 is the latest version available based on your source(s).
visualstudio2019-workload-vctools v1.0.1 is the latest version available based on your source(s).

Chocolatey upgraded 0/2 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Type ENTER to exit:

我第一次设置node.js时就得到了它。

reactjs node.js react-native chocolatey nps
1个回答
0
投票

修复了它,我必须在命令提示符下运行自我扫描,我发现了 2 个损坏的文件,现在已修复,一切正常:)

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