Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install canvas #1663

Closed
JcbSm opened this issue Sep 7, 2020 · 11 comments
Closed

Unable to install canvas #1663

JcbSm opened this issue Sep 7, 2020 · 11 comments

Comments

@JcbSm
Copy link

JcbSm commented Sep 7, 2020

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

  • v2.6.1
  • Windows 10
@CodeWithJosh875
Copy link

same error.

@Pomax
Copy link
Contributor

Pomax commented Sep 11, 2020

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
Copy link
Collaborator

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:

  • Add request to your package.json. node-pre-gyp will automatically use that instead of needle.
  • Use an earlier version of Node.js
  • Build from source (see readme)

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
Copy link
Author

JcbSm commented Sep 13, 2020

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

@JcbSm JcbSm closed this as completed Sep 13, 2020
@t3moc
Copy link

t3moc commented Jan 13, 2021

how to build for alpine linux: see #1486

@iamgabrielsoft
Copy link

iamgabrielsoft commented Jul 11, 2021

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

@Pomax
Copy link
Contributor

Pomax commented Jul 12, 2021

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
Copy link

i have the same error but i use macboook air M1

@iamgabrielsoft
Copy link

Filing an issue to who??

@Pomax
Copy link
Contributor

Pomax commented Sep 20, 2021

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.

@cent-dxv
Copy link

cent-dxv commented May 7, 2024

if you are using ##docker on your project do not waste your time fixing
use ubuntu docker image it works fine with it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants