I am working on a project from some years ago that I have to debug/get running again and so far it has been a pain. I was able to install most dependencies, but apart from one time I got lucky, but can not reproduce this, I always fail to install chartjs-node. I use node v12.18.1 and npm 6.14.5 and Visual Studio Code for the terminal.
Every time I try npm i chartjs-node
or npm i in
general I get the following:
....
c:\users\user\desktop\sensqbot\repo\node_modules\chartjs-node\node_modules\canvas\src\canvas.h(19): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "cairo.h": No such file or dire
ctory (Quelldatei wird kompiliert ..\src\CanvasPattern.cc) [C:\Users\User\Desktop\SensQBot\repo\node_modules\chartjs-node\node_modules\canvas\build\canvas.vcxproj]
c:\users\user\desktop\sensqbot\repo\node_modules\chartjs-node\node_modules\canvas\src\canvas.h(19): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "cairo.h": No such file or dire
ctory (Quelldatei wird kompiliert ..\src\CanvasRenderingContext2d.cc) [C:\Users\User\Desktop\SensQBot\repo\node_modules\chartjs-node\node_modules\canvas\build\canvas.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\User\Desktop\SensQBot\repo\node_modules\chartjs-node\node_modules\canvas
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN The package ava is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\cairo\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.6.13 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.6.13 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2021-08-03T16_49_06_319Z-debug.log
I followed guides for installing the dependencies like canvas and cairo and that should be fine, I have GTK manually installed to C:/GTK, I have the libjpeg installed, node-gyp is installed globally: https://github.com/Automattic/node-canvas/wiki/Installation%3A-Windows
And installing cairo and canvas went just fine, I just do not understand why I was able to install chartjs-node once and never again, unfortunately, I lost the folder, as I tested that I could have just copied it into the node_modules of a project and it would run.
Sry if the question is too unspecific, I am just a beginner with node/npm and have not written the project myself, so I just stumbled from error to error until it became closer to running. Please ask if you need a complete log or more specs. Thank you very much in advance.
What in the end at least got the project running, was the following:
npm install chart.js@2.7.*
npm install chartjs-node@^1.7.1 --force
npm install
So, when someone has a module that seems just impossible to install, I suggest running npm audit
, this showed me, that chartjs-node was also missing chart.js@2.7.
* and then I just had to force the install, I am almost sure, as I just ignored the errors, this will lead to problems later, but at least I have a build to try out for now! PS. also lowering the version of node-gyp might help for older projects, at least I had this feeling here.