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

Strange error on Mac #31

Open
michaelspeed opened this issue Jan 12, 2018 · 19 comments
Open

Strange error on Mac #31

michaelspeed opened this issue Jan 12, 2018 · 19 comments

Comments

@michaelspeed
Copy link

i get this error while using it with electron and react
TypeError: (0 , p.exec) is not a function
any ideas whats wrong?

@automation-stack
Copy link
Owner

@michaelspeed Could you provide any details?

@michaelspeed
Copy link
Author

using like this -
import {machineId, machineIdSync} from 'node-machine-id'; class somthing extends Component { render(){ let id = machineIdSync() <-- Throws error } }

@JM-Mendez
Copy link

JM-Mendez commented Feb 17, 2018

@michaelspeed exec is a child_process method, and node modules can only be used in the main process of electron.

*edited for clarity

@timfish
Copy link

timfish commented Mar 9, 2018

Node modules can be used in both the main and render processes of Electron. We're successfully using them in both including native ones. I'm about to use this module in both so I'll let you know if I have trouble.

@JM-Mendez
Copy link

JM-Mendez commented Mar 9, 2018

@timfish if you mean node modules like fs, spawn, fork, child_process etc, and not npm modules - they are only available from the main process. You can access them from the renderer by using the ipc or remote modules (which runs the code from the main process). I should have been clearer on that.

@timfish
Copy link

timfish commented Mar 11, 2018

No that's not correct. In the renderer you can directly access any node module including all the built in ones. Give it a try!

@timfish
Copy link

timfish commented Mar 11, 2018

Here is me just requiring child-process in the Electron renderer dev tools:

image

@JM-Mendez
Copy link

You're absolutely correct, @timfish. I checked an old electron project I worked on and we had node integration set to false. That's why I couldn't access nodejs modules from the renderer process.

@Raghav-Sao
Copy link

Hi...
any solution for mac?

@calebswank11
Copy link

bump

@incizzle
Copy link

Im also facing this problem aswell.

@davis-jordan
Copy link

Any solution to this yet? Having the same problem on Mac using Electron and React.

@patrickmichalina
Copy link

Same issue here!

@lambou
Copy link

lambou commented Dec 7, 2019

Hello!,
Having the same problem in react js app (typescript project).

import { machineIdSync } from 'node-machine-id';

const socket: SocketIOClient.Socket = connect(`${process.env.REACT_APP_SOCKET_IO_SERVER_URL}`, {
        query: {
            deviceId: machineIdSync()
        }
});

@greysonn
Copy link

greysonn commented Dec 7, 2019

I don't think it's possible to grab the machine id from the actual react front-end. If you're using Electron try getting the machine id from the main process and passing it through an ipc channel.

@lambou
Copy link

lambou commented Dec 7, 2019

I'm not using electron, but Thanks for replying

@greysonn
Copy link

greysonn commented Dec 7, 2019

I'm not using electron, but Thanks for replying

Even in the react app it's not possible for the browser to fetch the machine id. However, an alternative is browser fingerprinting if you don't have a process running in the machine: https://panopticlick.eff.org/static/browser-uniqueness.pdf

@danielehrhardt
Copy link

Use
remote.require('node-machine-id');
import { ElectronService as NgxService } from 'ngx-electron';
image

@samp-reston
Copy link

Has anyone found a solution to this?

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