Automattic / node-canvas

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

Unable to install canvas #1663

Closed JcbSm closed 4 years ago

JcbSm commented 4 years ago

I'm unsure why but when I tried the npm i canvas it isn't working at all. I'm getting a huge error.

Issue or Feature

Unable to install canvas

Steps to Reproduce

npm i canvas

> canvas@2.6.1 install C:\Users\Jacob\Documents\Discord Bot\PRISM\node_modules\canvas
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.6.1 and node@12.18.1 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.
gyp ERR! clean error
gyp ERR! stack Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\Jacob\Documents\Discord Bot\PRISM\node_modules\canvas\build\Release'
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "clean"
gyp ERR! cwd C:\Users\Jacob\Documents\Discord Bot\PRISM\node_modules\canvas
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js clean' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Jacob\Documents\Discord Bot\PRISM\node_modules\canvas\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Jacob\\Documents\\Discord Bot\\PRISM\\node_modules\\canvas\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\Jacob\Documents\Discord Bot\PRISM\node_modules\canvas
node-pre-gyp ERR! node -v v12.18.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js clean' (1)
npm WARN discord-akairo@8.0.0 requires a peer of sqlite@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord-akairo@8.0.0 requires a peer of sequelize@^5.2.12 but none is installed. You must install peer dependencies yourself.
npm WARN prism-bot@1.3.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.6.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@2.6.1 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\Jacob\AppData\Roaming\npm-cache\_logs\2020-09-07T16_52_12_186Z-debug.log

Your Environment

CodeWithJosh875 commented 4 years ago

same error.

Pomax commented 4 years ago

That log shows it's falling back to building node-canvas from source, which means it needs several things installed and available, as described in https://github.com/Automattic/node-canvas/wiki/Installation%3A-Windows -- did you do that?

zbjornson commented 4 years ago

There are two issues there. The first is failing prebuild downloads, which is the top part of #1511:


Installation fails with Node.js v12.16.3 and later

This is due to an upstream issue in the module that downloads prebuilds: tomas/needle#312. That issue is fixed and node-canvas has been updated to use it, but we're currently stuck trying to make prebuilds.

Workarounds:


The second is this

ENOTEMPTY: directory not empty, rmdir 'C:\Users\Jacob\Documents\Discord Bot\PRISM\node_modules\canvas\build\Release'

Not sure why that's an error, but try deleting your node_modules and trying again. Make sure you've follows the instructions for building from source that @Pomax linked to above.

JcbSm commented 4 years ago

Deleting node_modules and then running npm install fixed it, all I had to do was do npm i node-gyp for it to run non-locally

t3moc commented 3 years ago

how to build for alpine linux: see https://github.com/Automattic/node-canvas/issues/1486

iamgabrielsoft commented 3 years ago

I had the same issue too, Unable to solve my problem...

Pomax commented 3 years ago

Note that this issue got closed as resolved in September 2020, so you probably want to file a new issue with all the details that explain your particular setup, and steps to reproduce, if this is going wrong for you?

miguelescalera commented 3 years ago

i have the same error but i use macboook air M1

iamgabrielsoft commented 3 years ago

Filing an issue to who??

Pomax commented 3 years ago

Not "to", just file a new issue over on https://github.com/Automattic/node-canvas/issues/new and describe your exact setup with STR, since this issue is closed. Maybe you've run into a regression, maybe you've run into a completely different bug or wrong behaviour, but commenting on a closed issue doesn't really surface the fact that there might be something to look at for anyone.