Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.15k stars 1.17k forks source link

Error building canvas in newest node version #1915

Closed Dosojin1 closed 2 years ago

Dosojin1 commented 2 years ago

Hi,

I'm trying to build with node v17.0.1, but I get this error Can somebody help with?

E:\Discord Bot Maker\VincitBot>npm install canvas
npm ERR! code 1
npm ERR! path E:\Discord Bot Maker\VincitBot\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
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm ERR! C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.18362.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution". [E:\Discord Bot Maker\VincitBot\node_modules\canvas\build\canvas.vcxproj]
npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\mark2\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=E:\Discord Bot Maker\VincitBot\node_modules\canvas\build\Release\canvas.node --module_name=canvas --module_path=E:\Discord Bot Maker\VincitBot\node_modules\canvas\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (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.6
npm ERR! node-pre-gyp info using node@17.0.1 | win32 | x64
npm ERR! node-pre-gyp info check checked for "E:\Discord Bot Maker\VincitBot\node_modules\canvas\build\Release\canvas.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v102-win32-unknown-x64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v102-win32-unknown-x64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.8.0 and node@17.0.1 (node-v102 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v102-win32-unknown-x64.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@17.0.1 | 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@7.1.2
npm ERR! gyp info using node@17.0.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "C:\Users\mark2\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
npm ERR! gyp info find VS using VS2019 (16.4.29905.134) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! (node:4072) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn C:\Users\mark2\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\mark2\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'E:\\Discord Bot Maker\\VincitBot\\node_modules\\canvas\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\mark2\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\mark2\\AppData\\Local\\node-gyp\\Cache\\17.0.1\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\mark2\\AppData\\Local\\node-gyp\\Cache\\17.0.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\mark2\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\mark2\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\17.0.1\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=E:\\Discord Bot Maker\\VincitBot\\node_modules\\canvas',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'E:\\Discord Bot Maker\\VincitBot\\node_modules\\canvas\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@17.0.1 | win32 | x64
npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\mark2\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mark2\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=E:\\Discord Bot Maker\\VincitBot\\node_modules\\canvas\\build\\Release\\canvas.node" "--module_name=canvas" "--module_path=E:\\Discord Bot Maker\\VincitBot\\node_modules\\canvas\\build\\Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v102"
npm ERR! gyp ERR! cwd E:\Discord Bot Maker\VincitBot\node_modules\canvas
npm ERR! gyp ERR! node -v v17.0.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
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 'C:\Program Files\nodejs\node.exe C:\Users\mark2\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=E:\Discord Bot Maker\VincitBot\node_modules\canvas\build\Release\canvas.node --module_name=canvas --module_path=E:\Discord Bot Maker\VincitBot\node_modules\canvas\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v102' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (E:\Discord Bot Maker\VincitBot\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1062:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19043
npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Discord Bot Maker\\VincitBot\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd E:\Discord Bot Maker\VincitBot\node_modules\canvas
npm ERR! node-pre-gyp ERR! node -v v17.0.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.6
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mark2\AppData\Local\npm-cache\_logs\2021-10-28T10_40_23_707Z-debug.log
Dosojin1 commented 2 years ago

I think I found the error, why it does not work, but can't figure out how to fix. when I run "npm i canvas" I see that the builder is using node-gyp version 7.1.2

but if I run "node-gyp -v" I get v8.3.0

EDIT found a way to update to v8.3.0

error is still there ...

APillowEdwards commented 2 years ago

I am also having a similar issue, my logs are almost identical other than a 404 on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v102-linux-glibc-x64.tar.gz instead.

In my case it part of a Gitlab Runner execution of building a React app. There's been no change to the pipeline settings since yesterday, when it was working successfully. I assume that the prebuilt binaries are no longer available for some reason.

sjohns21 commented 2 years ago

Me, too

Dosojin1 commented 2 years ago

Found a solution to fix my problem

Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator).

Install dependencies and configuration manually

  1. Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio 2019 Community (using the "Desktop development with C++" workload)
  2. Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7
  3. Launch cmd, npm config set msvs_version 2019

It will take some time to install Visual Studio Build Tools so be patient.

If it still does not work, I can send you the build canvas folder

Dosojin1 commented 2 years ago

Here you go the build version for Node v17.0.1

canvas.zip

microcosmtoken commented 2 years ago

Error: dlopen(~/metaplex/js/packages/cli/node_modules/canvas/build/Release/canvas.node, 1): no suitable image found.

Still an issue, even on 17.0.1

itsryu commented 2 years ago

Yea, me too..

zbjornson commented 2 years ago

Prebuilds for Windows x64, node-canvas v2.8.0, Node.js v17 are now available.

ARR4NN commented 2 years ago

Sorry to reopen, I'm having issues on ubuntu node 17. When trying to start a discord bot with canvas and canvacord I get the error ode-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v83-linux-glibc-arm64.tar.gz node-pre-gyp WARN Pre-built binaries not installable for canvas@2.8.0 and node@14.18.1 (node-v83 ABI, glibc) (falling back to source compile with node-gyp) node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.8.0/canvas-v2.8.0-node-v83-linux-glibc-arm64.tar.gz

zbjornson commented 2 years ago

@ARR4NN that is a different issue, we don't provide ARM prebuilds. See #1511.

ARR4NN commented 2 years ago

@ARR4NN that is a different issue, we don't provide ARM prebuilds. See #1511.

could I ask why. Im sure it must be requested by many people. Im running my bot in a docker container can I still do that guide?

itsLOGIC-ui commented 2 years ago

SOME ONE PLZ HELP ME

THATS THE ERROR

PS E:\NFT\hashlips_art_engine-1.1.2_patch_v1> npm run generate

hashlips_art_engine@1.1.1 generate node index.js

node:internal/modules/cjs/loader:1179 return process.dlopen(module, path.toNamespacedPath(filename)); ^

Error: \?\E:\NFT\hashlips_art_engine-1.1.2_patch_v1\node_modules\canvas\build\Release\canvas.node is not a valid Win32 application. at Object.Module._extensions..node (node:internal/modules/cjs/loader:1179:18) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (E:\NFT\hashlips_art_engine-1.1.2_patch_v1\node_modules\canvas\lib\bindings.js:3:18) at Module._compile (node:internal/modules/cjs/loader:1097:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) { code: 'ERR_DLOPEN_FAILED'