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

TypeError: The "path" argument must be of type string. Received undefined #3763

Closed
3 tasks done
devzzzero opened this issue Nov 17, 2024 · 2 comments
Closed
3 tasks done

Comments

@devzzzero
Copy link

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.5.0

Electron version

v33.0.2

Operating system

OpenSuse 15.5

Last known working Electron Forge version

unknown

Expected behavior

Hi Please look at zeromq/zeromq.js#676 and
webpack/webpack#18987

When I add in zeromq as either a devDependency or a regular dependency,
and when I import any (working!) zeromq test code into index.ts (or renderer.ts), it begins to barf.

Here are the steps to reproduce this issue:

test-ui.zip

  1. npm init electron-app@latest test-ui -- --template=webpack-typescript
  2. unpack test-ui.zip into the directory. It contains updates to activate preact, sass, zeromq, etc..
  3. npm start (it should work)
  4. paste any working zeromq test code into either src/index.ts or src/renderer.ts
  5. npm start to see it fail like above

Here is a sample bit of (working) code you can paste into index.ts to see it fail

import * as zmq from "zeromq"

interface WatcherDesc {
  topic:string;
  sock:zmq.Subscriber;
};
class SocketMap extends Map<string,WatcherDesc> {};
class LogWatcher {
  url:string;
  sockets:SocketMap;
  constructor(topic:string, url:string="tcp://localhost:35501") {
    this.url = url;
    this.sockets = new SocketMap();

    const sock = new zmq.Subscriber();
    sock.connect(url);
    sock.subscribe(topic);
    console.log(`connected to ${url} for ${topic}`);
    this.sockets[topic] = { topic, sock  };

    // console.log(this.sockets);
    console.log(`for topic ${topic}`, this.sockets[topic]);
  };
};

const LM = new LogWatcher('foo');

Actual behavior

Error: Failed to load zeromq.js addon.node: TypeError: The "path" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at Object.join (node:path:1244:7)
    at findAddon (/home/work/test-app/test-ui/.webpack/main/index.js:2192:70)
    at ./node_modules/zeromq/lib/load-addon.js (/home/work/test-app/test-ui/.webpack/main/index.js:2221:15)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at ./node_modules/zeromq/lib/native.js (/home/work/test-app/test-ui/.webpack/main/index.js:2241:38)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at ./node_modules/zeromq/lib/index.js (/home/work/test-app/test-ui/.webpack/main/index.js:1560:16)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at ./src/LogWatcher.ts (/home/work/test-app/test-ui/.webpack/main/index.js:1140:26)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at findAddon (/home/work/test-app/test-ui/.webpack/main/index.js:2214:15)
    at ./node_modules/zeromq/lib/load-addon.js (/home/work/test-app/test-ui/.webpack/main/index.js:2221:15)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at ./node_modules/zeromq/lib/native.js (/home/work/test-app/test-ui/.webpack/main/index.js:2241:38)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at ./node_modules/zeromq/lib/index.js (/home/work/test-app/test-ui/.webpack/main/index.js:1560:16)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)
    at ./src/LogWatcher.ts (/home/work/test-app/test-ui/.webpack/main/index.js:1140:26)
    at __webpack_require__ (/home/work/test-app/test-ui/.webpack/main/index.js:2296:42)

Steps to reproduce

See above

Additional information

Help! Please!

@devzzzero
Copy link
Author

Please see webpack/webpack#18987
and
Richienb/node-polyfill-webpack-plugin#58

So it seems process polyfill has bitrotted and is not providing process.arch and process.platform, I don't quite yet understand what the proper fix for this should be.

Can a kind soul please chime in?

@VerteDinde
Copy link
Member

Hey @devzzzero , I think this is unfortunately a webpack configuration issue and not a Forge issue. It looks like you resolved it here, I hope it's working for you now!: niksy/node-stdlib-browser#33

I'm going to close this issue, but please let me know if you do think this is a Forge issue and we can try to address it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants