I installed cairo, and node-canvas. I tried everything, but still can’t find module.
sudo apt-get install libcairo2-dev
sudo npm install canvas
sudo npm install canvas -g
If I run require('canvas')
, I get this error:
Error: Cannot find module '../build/Release/canvas'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/home/tomas/node_modules/canvas/lib/bindings.js:2:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
I use Ubuntu linux
Thanks in advance.
hong4rc
3,9494 gold badges20 silver badges40 bronze badges
asked Feb 8, 2013 at 11:42
6
In my case i have to spend lot of time to resolve this issue.
I just use «npm uninstall canvas» and then install using «npm i canvas»
Try this is if above option not works for you.
answered Jul 30, 2020 at 14:55
1
It seemed like the install
script of canvas
haven’t been called in my case, too. Instead of deleting the lock file I just called the script manually which solved the issue in my case (at least temporarily).
Therefore, if the canvas
package has been installed already, go to /node_modules/canvas/ and run npm run install
which creates the build directory.
answered Nov 4, 2021 at 11:40
davstodavsto
4124 silver badges11 bronze badges
I had the same problem. The issue was that the install
script for node-canvas
never got executed, which is why the build
folder was missing.
In my case, removing the yarn.lock
file was the solution, as it skipped the node-canvas
package installation for some reason. Once I let npm
take care of the packages, it successfully installed node-canvas
, ran the install
script and the build folder showed up again.
answered Feb 14, 2017 at 13:16
Marcel KalveramMarcel Kalveram
1,2751 gold badge14 silver badges22 bronze badges
1
I had a similar problem but I used canvas-prebuilt which is a drop-in replacement for canvas and I fixed it for doing this:
npm install -g node-gyp and then node-gyp rebuild in the terminal
answered Feb 26, 2020 at 0:08
U can try it:
- Delete NodeModule Folder
- Use node version 14
- Run dependency installations
answered Jan 13 at 21:06
1
sudo apt-get install libpixman-1-dev libcairo2-dev libpangocairo-1.0-0 libpango1.0-dev libgif-dev libjpeg-dev
If use ubuntu,try install above lib then install canvas.work fine for me。
If you use cnpm install the canvas. try npm.
answered Feb 14, 2017 at 3:34
yo yoyo yo
891 silver badge4 bronze badges
Issue or Feature
Error: Build folder and the mentioned file don’t exist. Install method: npm install canvas
. Also tried
npm install canvs --build-from-source
(Verbose output is at the end of this post)
$ node index.js
internal/modules/cjs/loader.js:964
throw err;
^
Error: Cannot find module '../build/Release/canvas.node'
Require stack:
- /home/h/Dokumente/Phaser/node_modules/canvas/lib/bindings.js
- /home/h/Dokumente/Phaser/node_modules/canvas/lib/canvas.js
- /home/h/Dokumente/Phaser/node_modules/canvas/index.js
- /home/h/Dokumente/Phaser/node_modules/jsdom/lib/jsdom/utils.js
- /home/h/Dokumente/Phaser/node_modules/jsdom/lib/jsdom/browser/Window.js
- /home/h/Dokumente/Phaser/node_modules/jsdom/lib/api.js
- /home/h/Dokumente/Phaser/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17)
at Function.Module._load (internal/modules/cjs/loader.js:854:27)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/h/Dokumente/Phaser/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1128:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14)
at Module.require (internal/modules/cjs/loader.js:1023:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/h/Dokumente/Phaser/node_modules/canvas/lib/bindings.js',
'/home/h/Dokumente/Phaser/node_modules/canvas/lib/canvas.js',
'/home/h/Dokumente/Phaser/node_modules/canvas/index.js',
'/home/h/Dokumente/Phaser/node_modules/jsdom/lib/jsdom/utils.js',
'/home/h/Dokumente/Phaser/node_modules/jsdom/lib/jsdom/browser/Window.js',
'/home/h/Dokumente/Phaser/node_modules/jsdom/lib/api.js',
'/home/h/Dokumente/Phaser/index.js'
]
}
Steps to Reproduce
index.js:
const jsdom = require('jsdom');
Console:
$ node index.js
Your Environment
npm list —depth=0
/home/h/Dokumente/Phaser
├── canvas@2.6.0
└── jsdom@15.2.1
npm ERR! extraneous: minimist@1.2.0 /home/h/Dokumente/Phaser/node_modules/rc/node_modules/minimist
npm ERR! extraneous: acorn@6.4.0 /home/h/Dokumente/Phaser/node_modules/acorn-globals/node_modules/acorn
npm ERR! extraneous: cssom@0.3.8 /home/h/Dokumente/Phaser/node_modules/cssstyle/node_modules/cssom
npm ERR! extraneous: tough-cookie@2.4.3 /home/h/Dokumente/Phaser/node_modules/request/node_modules/tough-cookie
npm ERR! extraneous: tough-cookie@2.5.0 /home/h/Dokumente/Phaser/node_modules/request-promise-native/node_modules/tough-cookie
$ node -v
v13.3.0
OS:
Ubuntu 19.04
$ npm install canvas —verbose
npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/home/h/.nvm/versions/node/v13.3.0/bin/node',
npm verb cli '/home/h/.nvm/versions/node/v13.3.0/bin/npm',
npm verb cli 'install',
npm verb cli 'canvas',
npm verb cli '--verbose'
npm verb cli ]
npm info using npm@6.13.1
npm info using node@v13.3.0
npm verb npm-session 003e0920c9883fac
npm http fetch GET 304 https://registry.npmjs.org/canvas 112ms (from cache)
npm timing stage:loadCurrentTree Completed in 1153ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 10ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 612ms
npm http fetch GET 304 https://registry.npmjs.org/nan 35ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-get 62ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/node-pre-gyp 65ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/decompress-response 30ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-concat 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/mimic-response 24ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 1087ms
npm timing stage:loadIdealTree Completed in 1936ms
npm timing stage:generateActionsToTake Completed in 65ms
npm verb correctMkdir /home/h/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /home/h/.npm/_locks/staging-eb44e244cc61d316.lock for /home/h/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules/.staging
npm timing action:extract Completed in 178ms
npm info lifecycle canvas@2.6.0~preuninstall: canvas@2.6.0
npm info lifecycle canvas@2.6.0~uninstall: canvas@2.6.0
npm verb unbuild rmStuff canvas@2.6.0 from /home/h/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules
npm info lifecycle canvas@2.6.0~postuninstall: canvas@2.6.0
npm timing action:unbuild Completed in 2ms
npm timing action:remove Completed in 10ms
npm timing action:finalize Completed in 35ms
npm timing action:refresh-package-json Completed in 90ms
npm info lifecycle canvas@2.6.0~preinstall: canvas@2.6.0
npm timing action:preinstall Completed in 1ms
npm info linkStuff canvas@2.6.0
npm timing action:build Completed in 2ms
npm info lifecycle canvas@2.6.0~install: canvas@2.6.0
npm info lifecycle canvas@2.6.0~install: ignored because ignore-scripts is set to true canvas@2.6.0
npm timing action:install Completed in 5ms
npm info lifecycle canvas@2.6.0~postinstall: canvas@2.6.0
npm timing action:postinstall Completed in 1ms
npm verb unlock done using /home/h/.npm/_locks/staging-eb44e244cc61d316.lock for /home/h/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules/.staging
npm timing stage:executeActions Completed in 347ms
npm timing stage:rollbackFailedOptional Completed in 46ms
npm timing stage:runTopLevelLifecycles Completed in 3769ms
npm verb saving [ { name: 'canvas', spec: '^2.6.0', save: 'dependencies' } ]
npm timing audit submit Completed in 702ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 702ms
npm timing audit body Completed in 1ms
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm verb shrinkwrap skipping write for package-lock.json because there were no changes.
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN phaser3-multiplayer-example-with-geckos.io@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
~/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules/canvas$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@6.0.1
gyp info using node@13.3.0 | linux | x64
gyp info find Python using Python version 3.7.3 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/h/.nvm/versions/node/v13.3.0/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/h/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/h/.nvm/versions/node/v13.3.0/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/h/.cache/node-gyp/13.3.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/h/.cache/node-gyp/13.3.0',
gyp info spawn args '-Dnode_gyp_dir=/home/h/.nvm/versions/node/v13.3.0/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/h/.cache/node-gyp/13.3.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/h/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules/canvas',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pixman-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pixman-1' found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/home/h/.nvm/versions/node/v13.3.0/lib/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:219:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! System Linux 5.0.0-37-generic
gyp ERR! command "/home/h/.nvm/versions/node/v13.3.0/bin/node" "/home/h/.nvm/versions/node/v13.3.0/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/h/Dokumente/Phaser Projects/phaser3-multiplayer-game/node_modules/canvas
gyp ERR! node -v v13.3.0
gyp ERR! node-gyp -v v6.0.1
Содержание
- Error: Cannot find module ‘../build/Release/canvas’ #284
- Comments
- Error: Cannot find module ‘../build/Release/canvas.node’ #2135
- Comments
- Issue
- Your Environment
- cannot find module ‘../build/release/canvas.node’ error #1221
- Comments
- Can’t install canvas #1311
- Comments
- Can’t install canvas #1311
- Comments
Error: Cannot find module ‘../build/Release/canvas’ #284
Getting this issue under Debian.
checked out this repository and ran make
Tried to run the example, but no joy.
root@linuxlab:/home/tw-nodejs/lab/node-canvas/examples# node clock.js
module.js:340
throw err;
^
Error: Cannot find module ‘../build/Release/canvas’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/home/tw-nodejs/lab/node-canvas/lib/bindings.js:2:18)
at Module._compile (module.js:454:26)
at Object.Module._extensions..js (module.js:472:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
The text was updated successfully, but these errors were encountered:
I fought with this for a while today. First off I’m on Ubuntu 12.10 server. I’m new to node but it appeared that the npm was not building the package or placing it in the correct spot. The source was there, but if you looked at the ./build/release/canvas folder it wasn’t there. I ended up following the install instructions from the wiki here.
I removed the npm package and downloaded the source directly from git
The node-waf configure build command does not work there is no wscript file, however if you run
npm install -g node-gyp
then run:
node-gyp rebuild
in the node folder it proceeds to rebuild correctly.
After I completed that and pointed my require to the node-canvas folder it works!
I have the same problem. Looks like this issue has been around for over a year now.
benmorus44’s solution doesn’t work, node-gyp rebuild fails with build errors. The first error is:
I’ve found that version 1.0.4 builds fine. It looks like all later versions have problems. It doesn’t look like the devs give a fuck. And official docs still tell us to use node-waf, which no longer works.
@janek37 Original devs no longer work on this. @TooTallNate and @rvagg are helping here. I have commit rights but have very limited knowledge of C++ or anything related to installation/environment. And barely any time to start with. I’m maintaining this by merging simple PR’s or whatever @TooTallNate @rvagg approve.
@janek37 I asked for help on twitter but there’s still not enough manpower to handle all the issues, PR’s, etc.
I see. Thanks for reply!
I am experiencing the same issue. @benmorris44’s solution throws:
Any update on this one?
Update
I forgot to npm install to install dependencies. Ran it and now the error went away.
@sungwoncho ‘s suggestion did it for me. I got the error after doing an npm update , but doing npm install separately afterwards fixed the issue
@DrMiaow Did you solve this?
SOLINK_MODULE(target) Release/canvas-postbuild.node
CXX(target) Release/obj.target/canvas/src/Canvas.o
CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
In file included from ../src/CanvasPattern.cc:10:
../src/CanvasPattern.h:23:9: warning: private field ‘_width’ is not used [-Wunused-private-field]
int _width, _height;
^
../src/CanvasPattern.h:23:17: warning: private field ‘_height’ is not used [-Wunused-private-field]
int _width, _height;
^
2 warnings generated.
CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
CXX(target) Release/obj.target/canvas/src/color.o
CXX(target) Release/obj.target/canvas/src/Image.o
CXX(target) Release/obj.target/canvas/src/ImageData.o
CXX(target) Release/obj.target/canvas/src/init.o
CXX(target) Release/obj.target/canvas/src/FontFace.o
In file included from ../src/FontFace.cc:7:
../src/FontFace.h:27:15: warning: private field ‘_ftFace’ is not used [-Wunused-private-field]
FT_Face _ftFace;
^
1 warning generated.
SOLINK_MODULE(target) Release/canvas.node`
but then when I try to run browserify with babel (browserify -t babelify -o «outfile.js»), I get
Error: Cannot find module ‘../build/Release/canvas’ from ‘/Users/pbadger/Desktop/gigster/Seizin/node_modules/canvas/lib’
@gleerman What is the contents of your build/Release folder? I have
canvas-postbuild.node canvas.node obj.target (directory) — does the canvas.node file mean this isn’t an issue with canvas?
@pbadger You won’t be able to use this module in the browser since it’s built in C++ together with other compiled libraries.
Источник
Error: Cannot find module ‘../build/Release/canvas.node’ #2135
Issue
I have a project (nestjs) which works perfectly with canvas
I added nest-commander (which allows to create a cli command for my nest application).
When running the following command, the script fails:
Command:
Error:
It seems that when building with ts-node, it is unable to find the file ‘../build/Release/canvas.node’ for any reason.
If i remove the import < Canvas, Image >from ‘canvas’; line, script build with all other npm dependencies working.
Your Environment
- Version of node-canvas (output of npm list canvas or yarn list canvas ): canvas@2.9.3
- Environment (e.g. node 4.2.0 on Mac OS X 10.8): node 14.18.1 / npm 8.1.0
The text was updated successfully, but these errors were encountered:
for me reinstallation helped, even if canvas package is a sub-dependency
previously rm node_modules/canvas
I think I’ve tried every suggestion in every thread on the internet about this issue but its still happening. I’m using pnpm, and the error happens when trying to run tests with vitest.
There’s not enough info in the log to troubleshoot. What’s your npm install canvas output, and what happens if you use node instead of npx ts-node ?
I ended up getting around the problem by just replacing getContext with a no-op (using vitest):
I was having similar issues with
Was replaced with.
My dev environment (macOS) worked fine with the initial import statement, but production (AWS Linux) failed with the Can’t find / not supporting ES5 modules errors.
We’ve got the same issue going on in CICD-only. We installed amCharts as a third-party library, and while setting up Jest testing for the charts, everything’s working locally but the test job fails in Gitlab, it complains:
Источник
cannot find module ‘../build/release/canvas.node’ error #1221
I was able to successfully install canvas module as per their documentation and to meet my requirement i had to update the canvas module binding.gyp file to support the jpeg files
I was able to rebuild the canvas successfully without any errors except a bunch of warnings. But post build i even notice that the file canvas.node exists in the specified path. However when i try to consume it in my application it shoots up the error «The specified module could not be found» ‘../build/release/canvas.node’. I’m not sure if i’m missing something here, please suggest.
If I set «with_jpeg%» flag to false and rebuild then i do not see any errors while consuming the canvas module.
Windows Server 2016 — 64 Bit
node — v8.11.3
npm — v5.6.0
node-gyp — v3.8.0
python — v2.7.14
msvs_version — 2015
GTK — gtk+-bundle_2.22.1-20101229_win64
jpeglib — libjpeg-turbo-1.5.3-vc64
binding.gyp changes for jpeg support
Test Code which i’m executing
var Canvas = require(‘canvas’);
Error
module.js:681
return process.dlopen(module, path._makeLong(filename));
^
Error: The specified module could not be found.
?c. buildReleasecanvas.node
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (c:IQCanvasnode_modulescanvaslibbindings.js:3:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
The text was updated successfully, but these errors were encountered:
Источник
Can’t install canvas #1311
- Node Version: 4.7.2
- Platform: 4.10.0-37-generic
use ‘fstream’ everywhere during «install» #41 -Ubuntu x86_64 GNU/Linux
Verbose output (from npm or node-gyp):
If I remove the sudo, the errors go away and I get a bunch of warnings instead. Installing something else works [example. text-meme-cli], however when I try to run it, I get these errors:
It says it can’t find canvas.node. So I guess without sudo the installation still fails.
The text was updated successfully, but these errors were encountered:
The log doesn’t contain the actual build error but you should be able to find it in the console output.
Apologies, here’s the console output when I run sudo npm install canvas :
That’s a permissions error, probably because you installed as root first. Can you delete the node_modules folder and try again?
I deleted the node_modules folder referenced in the error output, which was located at home. but the same error persisted.
It even said gyp ERR! stack Error: EACCES: permission denied, mkdir ‘/home/textman/node_modules/canvas/build’ again, so I tried deleting the same node_modules folder again using rm -r.
And now it’s saying the folder doesn’t exist.
So the installer is trying to make a directory in a folder that doesn’t exist.
However, I tried making that directory myself, and rerunning the command, but the same error showed up.
I feel like the log is incorrect.
Getting this also, when trying to «rebuild node-gyp» which shouldn’t even be necessary because there should be prebuilt packages for the most common platforms:
Источник
Can’t install canvas #1311
- Node Version: 4.7.2
- Platform: 4.10.0-37-generic
use ‘fstream’ everywhere during «install» #41 -Ubuntu x86_64 GNU/Linux
Verbose output (from npm or node-gyp):
If I remove the sudo, the errors go away and I get a bunch of warnings instead. Installing something else works [example. text-meme-cli], however when I try to run it, I get these errors:
It says it can’t find canvas.node. So I guess without sudo the installation still fails.
The text was updated successfully, but these errors were encountered:
The log doesn’t contain the actual build error but you should be able to find it in the console output.
Apologies, here’s the console output when I run sudo npm install canvas :
That’s a permissions error, probably because you installed as root first. Can you delete the node_modules folder and try again?
I deleted the node_modules folder referenced in the error output, which was located at home. but the same error persisted.
It even said gyp ERR! stack Error: EACCES: permission denied, mkdir ‘/home/textman/node_modules/canvas/build’ again, so I tried deleting the same node_modules folder again using rm -r.
And now it’s saying the folder doesn’t exist.
So the installer is trying to make a directory in a folder that doesn’t exist.
However, I tried making that directory myself, and rerunning the command, but the same error showed up.
I feel like the log is incorrect.
Getting this also, when trying to «rebuild node-gyp» which shouldn’t even be necessary because there should be prebuilt packages for the most common platforms:
Источник
Issue
I’m using chartjs-node-canvas with chartjs to render a graph config as an image, so after installing it I tried the following :
import { ChartJSNodeCanvas } from 'chartjs-node-canvas';
const chartCallback = (ChartJS) => {
ChartJS.defaults.global.elements.rectangle.borderWidth = 2;
};
const canvasRenderService = new ChartJSNodeCanvas({
width,
height,
chartCallback,
});
But I get the following error when I’m creating a new ChartJSNodeCanvas :
Error: Cannot find module 'canvas'
at Function.webpackEmptyContext [as resolve] (http://localhost:4200/main.js:131373:10)
at freshRequire (http://localhost:4200/main.js:21530:69)
at new ChartJSNodeCanvas (http://localhost:4200/main.js:21592:50)
at ChartImageService._callee2$ (http://localhost:4200/main.js:127066:39)
at tryCatch (http://localhost:4200/main.js:115133:17)
at Generator.invoke [as _invoke] (http://localhost:4200/main.js:115347:22)
at Generator.next (http://localhost:4200/main.js:115185:21)
at http://localhost:4200/main.js:127002:67
at new ZoneAwarePromise (http://localhost:4200/polyfills.js:7278:21)
at __awaiter (http://localhost:4200/main.js:126981:10) {code: 'MODULE_NOT_FOUND', stack: 'Error: Cannot find module 'canvas'
at Fun…ter (http://localhost:4200/main.js:126981:10)', message: 'Cannot find module 'canvas''}
I tried to npm install again, npm rebuild, delete package-lock.json… but it doesn’t work. Any ideas ?
I’m using Angular with Electronjs
Solution
On https://www.npmjs.com/package/chartjs-node-canvas, there’s the following note:
Node JS version
This is limited by the upstream dependency canvas.
Therefore, your problem should be solved if you run the following commands:
npm install canvas
npm rebuild
Answered By — uminder
Я установил cairo и узел-холст. Я пробовал все, но все еще не могу найти модуль.
sudo apt-get install libcairo2-dev
sudo npm install canvas
sudo npm install canvas -g
Если я сбегу require('canvas')
, Я получаю эту ошибку:
Error: Cannot find module '../build/Release/canvas'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/home/tomas/node_modules/canvas/lib/bindings.js:2:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
Я использую убунту линукс
Заранее спасибо.
6 ответы
В моем случае я должен потратить много времени, чтобы решить эту проблему.
Я просто использую «npm uninstall canvas», а затем устанавливаю с помощью «npm i canvas».
Попробуйте это, если вышеуказанный вариант не работает для вас.
Создан 30 июля ’20, 15:07
У меня такая же проблема. Проблема заключалась в том, что install
сценарий для node-canvas
никогда не был казнен, поэтому build
папка отсутствовала.
В моем случае удаление yarn.lock
файл был решением, так как он пропустил node-canvas
установка пакета по какой-то причине. Однажды я позволю npm
позаботьтесь о пакетах, он успешно установлен node-canvas
побежал install
script, и папка сборки снова появилась.
Создан 14 фев.
Казалось, install
сценарий canvas
в моем случае тоже не вызывали. Вместо того, чтобы удалить файл блокировки, я просто вызвал скрипт вручную, который решил проблему в моем случае (по крайней мере, временно).
Следовательно, если canvas
пакет уже установлен, перейдите к /node_modules/холст/ и запустить npm run install
который создает каталог сборки.
Создан 04 ноя.
ответ дан 06 мар ’14, в 11:03
У меня была похожая проблема, но я использовал готовый холст, который является заменой холста, и я исправил его для этого:
npm установить -g узел-гип , а затем node-gyp восстановить в терминале
Создан 26 фев.
sudo apt-get install libpixman-1-dev libcairo2-dev libpangocairo-1.0-0 libpango1.0-dev libgif-dev libjpeg-dev
Если вы используете ubuntu, попробуйте установить библиотеку выше, а затем установите canvas. Работает нормально для меня。
Если вы используете cnpm, установите файл canvas. попробуй нпм.
Создан 15 фев.
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками
node.js
node-canvas
or задайте свой вопрос.
I installed cairo, and node-canvas. I tried everything, but still can’t find module.
sudo apt-get install libcairo2-dev sudo npm install canvas sudo npm install canvas -g
If I run
require('canvas')
, I get this error:Error: Cannot find module '../build/Release/canvas' at Function._resolveFilename (module.js:332:11) at Function._load (module.js:279:25) at Module.require (module.js:354:17) at require (module.js:370:17) at Object.<anonymous> (/home/tomas/node_modules/canvas/lib/bindings.js:2:18) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:32) at Function._load (module.js:308:12) at Module.require (module.js:354:17)
I use Ubuntu linux
Thanks in advance.
Answer
In my case i have to spend lot of time to resolve this issue.
I just use “npm uninstall canvas” and then install using “npm i canvas”
Try this is if above option not works for you.
Attribution
Source : Link , Question Author : friction , Answer Author : akshay_sushir
Я установил cairo и node -canvas. Я все пробовал, но не могу найти модуль.
sudo apt-get install libcairo2-dev
sudo npm install canvas
sudo npm install canvas -g
Если я запустил require('canvas')
, я получаю эту ошибку:
Error: Cannot find module '../build/Release/canvas'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/home/tomas/node_modules/canvas/lib/bindings.js:2:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
Я использую Ubuntu linux
Спасибо заранее,
Ответ 1
Проблема здесь выглядит
1. Ваши модули node установлены в другом месте. Но среда выполнения node.js ищет его в другом месте. Проверьте NODE_PATH и посмотрите, действительно ли это.
Обратитесь к загрузке модуля, объясненной в http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
Ответ 2
sudo apt-get install libpixman-1-dev libcairo2-dev libpangocairo-1.0-0 libpango1.0-dev libgif-dev libjpeg-dev
Если вы используете ubuntu, попробуйте установить выше lib, тогда установите canvas.work для меня.
Если вы используете cnpm, установите холст. попробуйте npm.
Ответ 3
У меня была та же проблема. Проблема заключалась в том, что install
script для node-canvas
никогда не выполнялся, поэтому папка build
отсутствовала.
В моем случае удаление файла yarn.lock
было решением, поскольку по какой-то причине оно пропустило установку пакета node-canvas
. Как только я дам npm
позаботиться о пакетах, он успешно установил node-canvas
, запустил install
script, и снова появилась папка сборки.