Electron app can only work in debug mode

Hello, I have an electron app used to test some 3rd part modules.In debug mode, everything is fine.When I build and package by using configuration 'Build-MacOS64',the app alerts 'Cannot find module electron-store'.

Someone has the same issue and the solution is here:

Seems like I have to modify the package.josn and move the dependencies from "DevDependencies" to "Dependencies", but I did not find it in package.json.

My test code is here:

dependences: npm i im_electron_sdk

Press the 'TIMGetSDKVersion' button to print SDK Version Code.

I found the reason, function "jsOnGetSDKVersion" and "jsOnGetSDKVersion_Error" invalid in release version.It is very strange, why they are available in debug mode but invalid in release mode??

Problem is resolved, I have to use a variable to pass the pointer of a method into ASM block,then it works in release mode.

I just want to know why,in order to avoid more mistakes


When compiling for release mode, any unused code will be removed for optimization. The JavaScript code in the asm blocks are ignored, so during compilation jsOnGetSDKVersion was detected as an unused method and was removed from the final JavaScript output. In your second version you reference jsOnGetSDKVersion when you do

tmpOnSycc := @jsOnGetSDKVersion;

so it's not detected as "unused" anymore.

Understood. Thanks @Tunde

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.