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

Error when using node-canvas in combination with gatsby-plugin-sharp #38525

Open
2 tasks done
f-kottek opened this issue Sep 6, 2023 · 0 comments
Open
2 tasks done

Error when using node-canvas in combination with gatsby-plugin-sharp #38525

f-kottek opened this issue Sep 6, 2023 · 0 comments
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@f-kottek
Copy link

f-kottek commented Sep 6, 2023

Preliminary Checks

Description

gatsby-plugin-sharp from version 5 onwards seems to be incompatible with node-canvas.

When running gatsby develop (or build for that matter) with the sharp.plugin enabled, the build will crash. Deactivating gatsby-plugin-sharp by removing it from the list in gatsby-config.js, the build/dev process will run just fine.
Please note: I am using node-canvas inside the node process, not in a react component.

Running node-canvas in gatsby v4 (with the corresponding sharp-plugin) works just fine.

This is what the error looks like:

Error in " [ ... ] root/gatsby-node": error: 127\\?\ [ ... ] root\node_modules\canvas\build\Release\canvas.node

Error: error: 127\\?\ [ ... ] root\node_modules\canvas\build\Release\canvas.node

note: i have replaced actual path to this project with "[ ... ] root"

I have also tried several method that where suggested to fix this issue, like:

Reproduction Link

https://github.com/f-kottek/gatsby-canvas-import-bug-repo

Steps to Reproduce

clone and install the repository (Obviously)

  1. run gatsby develop and watch it work + log some canvas-related stuff to the console. (Check gatsby-node)
  2. active gatsby-plugin-sharp inside gatsby-config
  3. re-run gatsby-develop and watch it fail when trying to import canvas.node

Expected Result

successful build with node-canvas working

Actual Result

Error in "D:/... /gatsby-node": error: 127\\?\...\node_modules\canvas\build\Release\canvas.node

  Error: error: 127\\? \...\node_modules\canvas\build\Release\canvas.node

  - loader:1340 Object.Module._extensions..node
    node:internal/modules/cjs/loader:1340:18

  - loader:1119 Module.load
    node:internal/modules/cjs/loader:1119:32

  - loader:960 Function.Module._load
    node:internal/modules/cjs/loader:960:12

  - loader:1143 Module.require
    node:internal/modules/cjs/loader:1143:19

  - helpers:121 require
    node:internal/modules/cjs/helpers:121:18

  - bindings.js:3 Object.<anonymous>
    [gatsby-5]/[canvas]/lib/bindings.js:3:18

  - loader:1256 Module._compile
    node:internal/modules/cjs/loader:1256:14

  - loader:1310 Object.Module._extensions..js
    node:internal/modules/cjs/loader:1310:10

  - loader:1119 Module.load
    node:internal/modules/cjs/loader:1119:32

  - loader:960 Function.Module._load
    node:internal/modules/cjs/loader:960:12

  - loader:1143 Module.require
    node:internal/modules/cjs/loader:1143:19
  - helpers:121 require
    node:internal/modules/cjs/helpers:121:18

  - canvas.js:9 Object.<anonymous>
    [gatsby-5]/[canvas]/lib/canvas.js:9:18

  - loader:1256 Module._compile
    node:internal/modules/cjs/loader:1256:14

  - loader:1310 Object.Module._extensions..js
    node:internal/modules/cjs/loader:1310:10

  - loader:1119 Module.load
    node:internal/modules/cjs/loader:1119:32

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor             
  Binaries:
    Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
    npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.10.0
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (116.0.1938.69)
  npmPackages:
    gatsby: ^5.12.3 => 5.12.3 
    gatsby-plugin-sharp: ^5.12.0 => 5.12.0 
  npmGlobalPackages:
    gatsby-cli: 5.9.0

Config Flags

No response

@f-kottek f-kottek added the type: bug An issue or pull request relating to a bug in Gatsby label Sep 6, 2023
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

1 participant