javascript 如何解决npm安装错误“npm ERR!代码1”?

0aydgbwb  于 2023-10-14  发布在  Java
关注(0)|答案(2)|浏览(366)

我正在尝试安装this项目,当我编写npm install时,我遇到了这个问题:

npm ERR! code 1
npm ERR! path C:\xampp\htdocs\sss\node_modules\deasync
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node ./build.js
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.1 found at "C:\Users\Admin\AppData\Local\Programs\Python\Python311\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community"npm ERR! gyp ERR! find VS checking VS2019 (16.11.33214.272) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - missing any VC++ toolset
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp ERR! stack     at C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
npm ERR! gyp ERR! stack     at C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
npm ERR! gyp ERR! stack     at C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
npm ERR! gyp ERR! stack     at C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:427:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\xampp\htdocs\sss\node_modules\deasync
npm ERR! gyp ERR! node -v v18.13.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! Build failed

我尝试重新安装Node.js,但没有帮助。我该怎么办?
我尝试重新安装Node.js,但没有帮助。我该怎么办?

k2fxgqgv

k2fxgqgv1#

看起来错误消息是说你需要先安装Visual Studio:
您需要安装最新版本的Visual Studio,包括“使用C++进行桌面开发”工作负载。有关详细信息,请参阅以下网址的文档:https://github.com/nodejs/node-gyp#on-windows“(示例网站)

68bkxrlz

68bkxrlz2#

通常,人们遇到这个错误可能是因为他们无法获得目标包的预编译二进制文件。
许多维护良好的软件包(C++附加组件)提供预编译的二进制文件,我们应该使用它们的原因是由于缺乏所需的编译环境,几乎不可能从源代码构建它
它不能保证包维护者将为每个执行环境提供预编译的二进制文件(由Node.js版本和操作系统决定)。您遇到此问题是因为您的环境中没有匹配的预编译二进制文件,或者您无法访问作者放置二进制文件的服务器。
如果是前一种情况,您可以升级Node.js或包以找到匹配的预编译二进制文件,这样npm就不会从源代码构建包

相关问题