Skip to content

The module 'webgl' was compiled against a different Node.js ABI version using NODE_MODULE_VERSION 115. This version of Bun requires NODE_MODULE_VERSION 127. Please try re-compiling or re-installing the module. #14105

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

Closed
PrinOrange opened this issue Sep 23, 2024 · 3 comments
Labels
bug Something isn't working needs triage

Comments

@PrinOrange
Copy link

What version of Bun is running?

1.1.30

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

First, install the GPU.JS

bun install gpu.js

And run this sample code

import { GPU } from 'gpu.js';

// This is a program for executing matrix multiplication with GPU.JS

const gpu = new GPU();

const multiplyMatrix = gpu.createKernel(function(a: number[][], b: number[][]) {
  let sum = 0;
  for (let i = 0; i < 512; i++) {
    sum += a[this.thread.y][i] * b[i][this.thread.x];
  }
  return sum;
}).setOutput([512, 512]);

const matrixA = Array.from({ length: 512 }, () => Array.from({ length: 512 }, () => Math.random()));
const matrixB = Array.from({ length: 512 }, () => Array.from({ length: 512 }, () => Math.random()));

const result = multiplyMatrix(matrixA, matrixB);

console.log(result);

Then the program crashed.

What is the expected behavior?

It should do utmost compatible for running program like what node.js does. The above code works in node.js, but crashes in bun

What do you see instead?

It throws such error information,

PS E:\frontend-projects\gpu-js> bun run index.ts
107 |         return opts[p] || p;
108 |       })
109 |     );
110 |     tries.push(n);
111 |     try {
112 |       b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
                                                     ^
error: The module 'webgl' was compiled against a different Node.js ABI version using NODE_MODULE_VERSION 115. 
This version of Bun requires NODE_MODULE_VERSION 127. Please try re-compiling or re-installing the module.
      at bindings (E:\frontend-projects\gpu-js\node_modules\bindings\bindings.js:112:48)
      at E:\frontend-projects\gpu-js\node_modules\gl\src\javascript\native-gl.js:1:7
      at E:\frontend-projects\gpu-js\node_modules\gl\src\javascript\webgl-rendering-context.js:4:42
      at E:\frontend-projects\gpu-js\node_modules\gl\src\javascript\node-index.js:3:32
      at E:\frontend-projects\gpu-js\node_modules\gl\index.js:4:10
      at E:\frontend-projects\gpu-js\node_modules\gpu.js\src\backend\headless-gl\kernel.js:1:7
      at E:\frontend-projects\gpu-js\node_modules\gpu.js\src\gpu.js:5:9
      at E:\frontend-projects\gpu-js\node_modules\gpu.js\src\index.js:1:9

Bun v1.1.30-canary.27+d05070dbf (Windows x64)

Additional information

No response

@PrinOrange PrinOrange added bug Something isn't working needs triage labels Sep 23, 2024
@birkskyum
Copy link
Collaborator

When I've accounted this issue, I've generally had to go into node_modules/gl and run npm install --build-from-source.

@190n
Copy link
Collaborator

190n commented Sep 23, 2024

This is related to V8 API support. The reason you see that issue is that you have an older version of Node.js installed, which is different than the version that Bun pretends to be for V8 modules (currently 22.6.0), so the native module got compiled for an old version of Node.js and Bun won't be compatible with it.

This needs to be fixed, probably somewhere in bun install so that it builds against the correct version of Node.js. You can try to work around the issue by installing dependencies with the environment variable npm_config_target=v22.6.0 set (this tells node-gyp which version of Node.js to compile for):

$env:npm_config_target = 'v22.6.0';
bun install

However, if you do that you'll probably just run into a different issue because Bun still doesn't support very much of the V8 API. You can track support in issue #4290.

@icavalheiro
Copy link

Bun is not compatible with the npm package "gl"

@190n 190n closed this as completed Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

4 participants