Skip to content

[Linux] Can't open libasound.so.2 #165

@Aworldc

Description

@Aworldc

Coming from Tonejs/Tone.js#309, trying to get tone to work under node.

Added the following into my main.js in hopes :

import { OfflineAudioContext } from 'node-web-audio-api'
globalThis.window = { OfflineAudioContext }

Got the following error:

[nix-shell:~/sp]$ node src/main.js
node:internal/modules/cjs/loader:1661
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libasound.so.2: cannot open shared object file: No such file or directory
    at Module._extensions..node (node:internal/modules/cjs/loader:1661:18)
    at Module.load (node:internal/modules/cjs/loader:1266:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12)
    at Module.require (node:internal/modules/cjs/loader:1289:19)
    at require (node:internal/modules/helpers:182:18)
    at Object.<anonymous> (/home/allan/sp/node_modules/.pnpm/node-web-audio-api@1.0.7/node_modules/node-web-audio-api/load-native.cjs:56:27)
    at Module._compile (node:internal/modules/cjs/loader:1521:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
    at Module.load (node:internal/modules/cjs/loader:1266:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v20.19.6

Searched the library, found it should be in the alsa-lib package on nixos, but I get the error even with the following packages installed:

let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-25.11";
  pkgs = import nixpkgs { config = {}; overlays = []; };
in

pkgs.mkShellNoCC {
  packages = with pkgs; [
    deno
    ffmpeg
    python311
    imagemagick
    alsa-lib
  ];
}

Where do I even start to debug this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions