Skip to content

netlify dev reload causes error: "Module did not self-register" with node-canvas #2641

@amerkay

Description

@amerkay

Describe the bug

Any time I change any file inside my netlify/functions/ folder, the node-canvas module fails to load on the next request. I have to stop netlify dev and rerun it.

To Reproduce

Simple code to reproduce uploaded here:
https://github.com/amerkay/netlify-cli-dev-bug

Steps to reproduce the behavior:

  1. Run locally using netlify dev.
    Then check the output at http://localhost:8888/.netlify/functions/test-canvas
  2. Change anything in the function's file test-canvas.js, like changing the text string. This triggers a function reload.
    "◈ .../netlify/functions/test-canvas.js modified, successfully reloaded!"
  3. Refresh the /test-canvas function in the browser, now you get the error:
    "Error: Module did not self-register"

Configuration

Happens without any toml config.

npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli

  System:
    OS: Linux 5.12 Manjaro Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 3.95 GB / 15.56 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.22.0 - /usr/bin/node
    npm: 7.15.0 - /usr/bin/npm
  npmGlobalPackages:
    netlify-cli: 3.34.0

Expected behavior

I should not get the error "Module did not self-register"

Additional context

  • Issue does not occur once deployed to Netlify.
  • The issue happens not just on my Linux machine, but also on MacOS.
  • Happens whether I use default bundler or esbuild.
  • Happens with npm@6 or npm@7
  • Example simple function uploaded to this repo

Much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions