bytenode/bytenode

Not be able to use path.join

JNLei opened this issue · 9 comments

JNLei commented

After long time debugging, I found using path.join will cause the app to crash.
I also see the limitation has:

Any code depends on Function.prototype.toString function will break

Is this the root cause of not be able to use path.join?
If so, how come the app works fine on Windows but not on Mac. I keep getting undefined is not a function wherever I used path.join on Mac.

path.join works and always worked with no issues. It has nothing to do with the Function.prototype.toString limitation.

If you can create a minimal example that shows your error on mac, I will check and try to figure it out.

JNLei commented

Here is the minimal example. I just clone the electron example, and upgrade to use electron 21.0.1.

electron-hello-world.zip

When you run rpm start, everything goes fine, but after run nom run build and open the binary, the following error shows:
Screen Shot 2022-12-08 at 8 44 37 PM

From the console log result, I can see the issue happens when path.join is called.

I'm using Mac OS Version 12.0 with M1, and I'm using Rosetta Terminal to build. Node version: 16.14.2

Thanks!

For some reason, npm run build throws this error on my machine:

osama@Mac-mini electron-hello-world % 
 npm run build

> electron-hello-world@0.0.1 build /Users/osama/Desktop/Dev/electron-hello-world
> electron-builder --x64

Error: Cannot find module 'fs/promises'
.
.
.

The electron example in bytenode repo is quite old. I think it's better to try the current official quick example from electron website.

I'm a bit busy currently, but I will try to put a minimal example using electron-builder to figure out the issue.

JNLei commented

Use Node v14+ to build should solve the issue @OsamaAbbas

I updated my node.js version to v18 and I was able to build the example.

However, I could not produce your error. Your app works fine whether it's npm run start or npm run build.

I'm using macOS Monterey (version 12.6) too, the default terminal though, and with node v18.12.1.

JNLei commented

I was also able to build, I met the above error when I ran the binary that was built.

Yeah, I was able to run the app that was built.

JNLei commented

I managed to have the M1 version built success. Still have some issues with the intel version, but it has nothing to do with bytenode. Thanks for your help! @OsamaAbbas . Closing the issue.

The only thing that I may mention is that you have to build your app for each platform separately. The binaries that were built for Intel won't work for M1 and vice versa.

Good luck with your project.