zeromq.js icon indicating copy to clipboard operation
zeromq.js copied to clipboard

Error when trying to `require("zeromq")`

Open AayushSabharwal opened this issue 3 years ago • 1 comments

Describe the bug Simply trying to require("zeromq") doesn't work.

Reproducing

mkdir test
cd test
npm install [email protected] # or zeromq@5
npm install -D parcel
touch index.html
touch index.js
npx parcel index.html

Contents of index.html:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>React App</title>
    </head>
    <body>
        <noscript>You need to enable JavaScript to run this app.</noscript>
        <div id="root"></div>
        <script type="module" src="index.js"></script>
    </body>
</html>

Contents of index.js:

const zmq = require("zeromq");

Parcel runs a server on localhost:1234. On opening this in Chrome, the following error pops up in the console:

index.js:29 Uncaught TypeError: Path must be a string. Received undefined
    at assertPath (index.js:29)
    at Object.dirname (index.js:294)
    at Function.load.path (index.js:43)
    at load (index.js:21)
    at Object.j8rSo.node-gyp-build (binding.js:1)
    at newRequire (index.3d214d75.js:71)
    at localRequire (index.3d214d75.js:84)
    at Object.4jqtO.buffer (index.js:19)
    at newRequire (index.3d214d75.js:71)
    at localRequire (index.3d214d75.js:84)

Expected behavior There shouldn't be an error.

Tested on

  • OS: EndeavourOS Linux x86_64
  • Kernel: 5.15.10-arch1-1
  • ZeroMQ.js version: 5.2.8, 6.0.0-beta.6

AayushSabharwal avatar Jan 21 '22 14:01 AayushSabharwal

I've also tried npm install [email protected] --build-from-source

AayushSabharwal avatar Jan 21 '22 14:01 AayushSabharwal

v6 has been released. Please upgrade to the latest version.

aminya avatar Sep 16 '24 05:09 aminya