|
30鱼币
在安装canvas的时候出现了如下的报错,请问我该怎么做呢?
- npm WARN cleanup Failed to remove some directories [
- npm WARN cleanup [
- npm WARN cleanup 'C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas',
- npm WARN cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\node_modules\readable-stre
- am\lib'] {
- npm WARN cleanup errno: -4048,
- npm WARN cleanup code: 'EPERM',
- npm WARN cleanup syscall: 'rmdir',
- npm WARN cleanup path: 'C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas\\node_modules\\readable-stream\\lib'
- npm WARN cleanup }
- npm WARN cleanup ],
- npm WARN cleanup [
- npm WARN cleanup 'C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas',
- npm WARN cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\node_modules\@mapbox\node-
- pre-gyp\lib'] {
- npm WARN cleanup errno: -4048,
- npm WARN cleanup code: 'EPERM',
- npm WARN cleanup syscall: 'rmdir',
- npm WARN cleanup path: 'C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas\\node_modules\\@mapbox\\node-pre-gyp\\lib'
- npm WARN cleanup }
- npm WARN cleanup ]
- npm WARN cleanup ]
- npm ERR! code 1
- npm ERR! path C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas
- npm ERR! command failed
- npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build --update-binary
- npm ERR! Failed to execute 'D:\softwares\PYTHON\node\node.exe D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure
- --fallback-to-build --update-binary --module=C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\build\Release\canvas.node --module_name=canvas -
- -module_path=C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node
- _napi_label=node-v108' (1)
- npm ERR! node-pre-gyp info it worked if it ends with ok
- npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
- npm ERR! node-pre-gyp info using node@18.16.0 | win32 | x64
- npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-win32-unknown-x64.tar.gz
- npm ERR! node-pre-gyp ERR! install request to https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-win32-unknow
- n-x64.tar.gz failed, reason: read ECONNRESET
- npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and node@18.16.0 (node-v108 ABI, unknown) (falling back to source compi
- le with node-gyp)
- npm ERR! node-pre-gyp WARN Hit error request to https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-win32-unkn
- own-x64.tar.gz failed, reason: read ECONNRESET
- npm ERR! gyp info it worked if it ends with ok
- npm ERR! gyp info using node-gyp@9.3.1
- npm ERR! gyp info using node@18.16.0 | win32 | x64
- npm ERR! gyp info ok
- npm ERR! gyp info it worked if it ends with ok
- npm ERR! gyp info using node-gyp@9.3.1
- npm ERR! gyp info using node@18.16.0 | win32 | x64
- npm ERR! gyp info find Python using Python version 3.11.1 found at "D:\softwares\PYTHON\pppy\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 could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
- 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 (D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47
- )
- npm ERR! gyp ERR! stack at D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
- npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\lib\find-visual
- studio.js:369:14)
- npm ERR! gyp ERR! stack at D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
- npm ERR! gyp ERR! stack at D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:390:16
- npm ERR! gyp ERR! stack at D:\softwares\PYTHON\node\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
- npm ERR! gyp ERR! stack at D:\softwares\PYTHON\node\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.19044
- npm ERR! gyp ERR! command "D:\\softwares\\PYTHON\\node\\node.exe" "D:\\softwares\\PYTHON\\node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gy
- p.js" "configure" "--fallback-to-build" "--update-binary" "--module=C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas\\build\\Release\\ca
- nvas.node" "--module_name=canvas" "--module_path=C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas\\build\\Release" "--napi_version=8" "-
- -node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
- npm ERR! gyp ERR! cwd C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas
- npm ERR! gyp ERR! node -v v18.16.0
- npm ERR! gyp ERR! node-gyp -v v9.3.1
- npm ERR! gyp ERR! not ok
- npm ERR! node-pre-gyp ERR! build error
- npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'D:\softwares\PYTHON\node\node.exe D:\softwares\PYTHON\node\node_modules\npm\node_modules\nod
- e-gyp\bin\node-gyp.js configure --fallback-to-build --update-binary --module=C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\build\Release\can
- vas.node --module_name=canvas --module_path=C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\build\Release --napi_version=8 --node_abi_napi=nap
- i --napi_build_version=0 --node_napi_label=node-v108' (1)
- npm ERR! node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas\node_modules\@mapbox\node-pr
- e-gyp\lib\util\compile.js:89:23)
- npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
- npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1091:16)
- npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:302:5)
- npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19044
- npm ERR! node-pre-gyp ERR! command "D:\\softwares\\PYTHON\\node\\node.exe" "C:\\Users\\肥宅SRP\\AppData\\Roaming\\npm\\node_modules\\canvas\\node_modul
- es\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
- npm ERR! node-pre-gyp ERR! cwd C:\Users\肥宅SRP\AppData\Roaming\npm\node_modules\canvas
- npm ERR! node-pre-gyp ERR! node -v v18.16.0
- npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
- npm ERR! node-pre-gyp ERR! not ok
- npm ERR! A complete log of this run can be found in:
- npm ERR! C:\Users\肥宅SRP\AppData\Local\npm-cache\_logs\2023-04-15T12_08_46_327Z-debug-0.log
- D:\softwares\PYTHON\pythonProject>
复制代码
从你提供的错误日志来看,这个问题主要是因为在安装 canvas 时,没有找到合适的 Visual Studio 安装。为了解决这个问题,你需要按照以下步骤操作:
1、首先确保你已经安装了最新版本的 Visual Studio(2019 或更新版本)。你可以从这里下载并安装它:https://visualstudio.microsoft.com/downloads/
2、在安装 Visual Studio 时,务必选择 "Desktop development with C++" 工作负载。这将确保你的系统上安装了必要的 C++ 工具链和库。
3、安装 Visual Studio 之后,重新启动命令提示符或 PowerShell。确保以管理员身份运行。
4、清理可能已损坏的 npm 缓存,运行以下命令:
npm cache clean --force
5、重新尝试安装 canvas:
npm install canvas
这样应该可以解决你的问题。如果问题仍然存在,请随时告知,以便我可以提供进一步的帮助。
|
最佳答案
查看完整内容
从你提供的错误日志来看,这个问题主要是因为在安装 canvas 时,没有找到合适的 Visual Studio 安装。为了解决这个问题,你需要按照以下步骤操作:
1、首先确保你已经安装了最新版本的 Visual Studio(2019 或更新版本)。你可以从这里下载并安装它:https://visualstudio.microsoft.com/downloads/
2、在安装 Visual Studio 时,务必选择 "Desktop development with C++" 工作负载。这将确保你的系统上安装了必要的 C++ 工 ...
|