I am trying this sample code for WebGL and the problem is that my build getting failed. Here is my code.
jslib
margeInto(LibraryManager.library,{
GameObjectHasClicked : function (str){
window.alert(Pointer_stringify(str));
},
Hello: function (){
window.alert(Pointer_stringify(str));
},
});
And UnityC# script
using System.Runtime.InteropServices;
using UnityEngine;
public class SendInfoToBrowserJS : MonoBehaviour {
[DllImport("__Internal")]
private static extern void GameObjectHasClicked(string pos);
[DllImport("__Internal")]
private static extern void Hello();
private void OnMouseDown()
{
string currentPos = this.transform.position.ToString();
Debug.Log("cube clicked "+ currentPos);
//#if UNITY_WEBGL
Hello();
GameObjectHasClicked(currentPos);
//#endif
}
}
As you can see that I am calling two simple methods (GameObjectHasClicked,Hello) of jslib from C#, but
First, it giving me error whenever I click the gameobject in editor mode
EntryPointNotFoundException: Hello
SendInfoToBrowserJS.OnMouseDown () (at Assets/Scripts/SendInfoToBrowserJS.cs:29)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
Second, the build is failing with success (but no build) message as well. Actually there are three messsages:
The first Error Message:
Failed running "C:/Program
Files/Unity2018.2.10/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe"
"C:/Program
Files/Unity2018.2.10/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten\emcc"
#"D:\#TLL_Projects\WebGLAndBroswerJSInteraction\Assets\..\Temp\emcc_arguments.resp"
stdout: stderr:WARNING:root:--separate-asm works best when compiling
to HTML. Otherwise, you must yourself load the '.asm.js' file that is
emitted separately, and must do so before loading the main '.js' file.
[-Wseparate-asm] error: failure to execute js library
"D:\#TLL_Projects\WebGLAndBroswerJSInteraction\Assets\Plugins\ExternalJSMethod.jslib":
ReferenceError: margeInto is not defined,,ReferenceError: margeInto is
not defined at eval (eval at load (eval at globalEval (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8)),
<anonymous>:1:1) at Object.load (eval at globalEval (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8),
<anonymous>:178:9) at JSify (eval at globalEval (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8),
<anonymous>:84:20) at
D:\#TLL_Projects\WebGLAndBroswerJSInteraction\Assets\Plugins\ExternalJSMethod.jslib
(C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:208:3)
at Module._compile (module.js:570:32) at
Object.Module._extensions..js (module.js:579:10) at Module.load
(module.js:487:32) at tryModuleLoad (module.js:446:12) at
Function.Module._load (module.js:438:3) at Module.runMain
(module.js:604:10)preprocessed source (you can run a js engine on this
to get a clearer error message
sometimes):=============margeInto(LibraryManager.library,{ GameObjectHasClicked
: function (str){ window.alert(Pointer_stringify(str)); }, Hello:
function
(){ window.alert(Pointer_stringify(str)); },});=============Internal
compiler error in src/compiler.js! Please raise a bug report at
https://github.com/kripken/emscripten/issues/ with a log of the build
and the input files used to run. Exception message: "ReferenceError:
margeInto is not defined" | ReferenceError: margeInto is not defined
at eval (eval at load (eval at globalEval (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8)),
<anonymous>:1:1) at Object.load (eval at globalEval (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8),
<anonymous>:178:9) at JSify (eval at globalEval (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8),
<anonymous>:84:20) at Object.<anonymous> (C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:208:3)
at Module._compile (module.js:570:32) at
Object.Module._extensions..js (module.js:579:10) at Module.load
(module.js:487:32) at tryModuleLoad (module.js:446:12) at
Function.Module._load (module.js:438:3) at Module.runMain
(module.js:604:10)Traceback (most recent call last): File
"C:/Program
Files/Unity2018.2.10/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten\emcc",
line 10, in <module>
python_selector.run(__file__, profile=True) File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\python_selector.py",
line 43, in run
sys.exit(run_by_import(filename, main) if on_allowed_version() else run_by_subprocess(filename)) File "C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\python_selector.py",
line 13, in run_by_import
return getattr(importlib.import_module(os.path.basename(filename)), main)()
File "C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc.py",
line 1611, in run
final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args) File "C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\shared.py",
line 2009, in emscripten
call_emscripten(cmdline) File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py",
line 2340, in _main
temp_files.run_and_clean(lambda: main( File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\tempfiles.py",
line 93, in run_and_clean
return func() File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py",
line 2345, in <lambda>
DEBUG=DEBUG, File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py",
line 2251, in main
temp_files=temp_files, DEBUG=DEBUG) File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py",
line 99, in emscript
glue, forwarded_data = compiler_glue(metadata, settings, libraries, compiler_engine, temp_files, DEBUG) File "C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py",
line 226, in compiler_glue
glue, forwarded_data = compile_settings(compiler_engine, settings, libraries, temp_files) File "C:\ProgramFiles\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py",
line 532, in compile_settings
cwd=path_from_root('src'), error_limit=300) File "C:\Program Files\Unity2018.2.10\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\jsrun.py",
line 132, in run_js
raise Exception('Expected the command ' + str(command) + ' to finish with return code ' + str(assert_returncode) + ', but it
returned with code ' + str(proc.returncode) + ' instead! Output: ' +
str(ret)[:error_limit]) Exception: Expected the command ['C:/Program
Files/Unity2018.2.10/Editor/Data\\Tools\\nodejs\\node.exe',
'--stack_size=8192', '--max-old-space-size=4096', 'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\Emscripten\\src\\compiler.js',
'C:\\Users\\User\\AppData\\Local\\Temp\\tmppocs11.txt', 'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Audio.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Cursor.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Eval.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\FileSystem.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Logging.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Profiler.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\SystemInfo.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\UnetWebSocket.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Video.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebCam.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebGL.js',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebRequest.js',
'D:\\#TLL_Projects\\WebGLAndBroswerJSInteraction\\Assets\\Plugins\\ExternalJSMethod.jslib',
'C:\ProgramFiles\\Unity2018.2.10\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\Emscripten\\src\\library_pthread_stub.js']
to finish with return code 0, but it returned with code 1 instead!
Output: // The Module object: Our interface to the outside world. We
import // and export values on it. There are various ways Module can
be used: // 1. Not defined. We create it here // 2. A function
parameter, function(Module) { ..generated code.. } // 3. pre-run
appended it, var Module = {}; ..generated
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
The second Error Message
Exception: Failed building WebGL Player.
UnityEditor.WebGL.ProgramUtils.StartProgramChecked
(System.Diagnostics.ProcessStartInfo p) (at
/Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/ProgramUtils.cs:48)
UnityEditor.WebGL.WebGlBuildPostprocessor.EmscriptenLink
(BuildPostProcessArgs args, Boolean wasmBuild, System.String
sourceFiles, System.String sourceFilesHash) (at
/Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:425)
UnityEditor.WebGL.WebGlBuildPostprocessor.LinkBuild
(BuildPostProcessArgs args) (at
/Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:474)
UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess
(BuildPostProcessArgs args) (at
/Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:937)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess
(BuildPostProcessArgs args, UnityEditor.BuildProperties&
outProperties) (at
C:/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:27)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTargetGroup
targetGroup, BuildTarget target, System.String installPath,
System.String companyName, System.String productName, Int32 width,
Int32 height, BuildOptions options, UnityEditor.RuntimeClassRegistry
usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at
C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:287)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
And the last success message
Build completed with a result of 'Succeeded'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I closely inspect my First error
Failed running "C:/Program
Files/Unity2018.2.10/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe"
"C:/Program
Files/Unity2018.2.10/Editor/Data/PlaybackEngines/WebGLSupport\BuildTools\Emscripten\emcc"
#"D:#TLL_Projects\WebGLAndBroswerJSInteraction\Assets..\Temp\emcc_arguments.resp"
stdout: stderr:WARNING:root:--separate-asm works best when compiling
to HTML. Otherwise, you must yourself load the '.asm.js' file that is
emitted separately, and must do so before loading the main '.js' file.
[-Wseparate-asm] error: failure to execute js library
"D:#TLL_Projects\WebGLAndBroswerJSInteraction\Assets\Plugins\ExternalJSMethod.jslib":
ReferenceError: margeInto is not defined,,ReferenceError: margeInto is
not defined at eval (eval at load (eval at globalEval (C:\Program . .. . .**so on**
and found that the problem is here
ReferenceError: **margeInto is not defined**,,ReferenceError: margeInto is
not defined at eval (eval at load
Actually it is mergeInto not margeInto, by replacing the syntax error i am able to build successfully.
I'm currently very interested in the comprehensive opportunites granted by electron.js and its modules. Unfortunately, I keep getting the same error in my renderer process (named 'connector.js') when trying to start my application.
Here is the error:
App threw an error during load
TypeError: Cannot match against 'undefined' or 'null'.
at Object.<anonymous> (D:\Eigene Dateien\Desktop\Coding\DesktopApps\EVT\extFunctions\connector\connector.js:2:44)
at Object.<anonymous> (D:\Eigene Dateien\Desktop\Coding\DesktopApps\EVT\extFunctions\connector\connector.js:22:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Eigene Dateien\Desktop\Coding\DesktopApps\EVT\main.js:9:1)
And here is my connector.js:
const $ = require('jquery');
const {BrowserWindow} = require('electron').remote;
let Remotewin = remote.getFocusedWindow();
$("#minimize").click(function(){
Remotewin.minimize();
});
$("#maximize").click(function(){
if(!Remotewin.isMaximized()){
Remotewin.maximize();
}else{
Remotewin.unmaximize();
}
});
$("#close").click(function(){
Remotewin.close();
});
As you can see clearly, I wanted to create my own menubar at the top frame of the window, but the functionality is getting seemingly demolished by this error. I already searched half of the internet and stackoverflow, but the every answer I found refered to a webpack and/or electron bug they couldn't directly influence.
That's why I want to clearly point out, that I am NOT using webpack in this project. Only external module I added is jquery, as you can see in the code.
So my question; Have you experiended this error in this context and do you maybe even know a solution? Or can you refer to someone with similiar problems?
Thank you in advance, J0nny
Since getFocusedWindow() is a a static method of BrowserWindow,
let Remotewin = remote.getFocusedWindow();
should be:
let Remotewin = BrowserWindow.getFocusedWindow();
I can't load the libphonenumber. I get this stack trace that I can't figure out.
The error occurs at the require line:
var gp = require('google-libphonenumber').PhoneNumberUtil.getInstance();
number.js:1058
throw a;
^
AssertionError: Assertion failed
at new goog.asserts.AssertionError (...../node_modules/google-libphonenumber/dist/libphonenumber.js:1051:20)
at Object.goog.asserts.doAssertFailure_ (..../node_modules/google-libphonenumber/dist/libphonenumber.js:1068:7)
at Object.goog.asserts.assert [as assert] (..../node_modules/google-libphonenumber/dist/libphonenumber.js:1075:53)
at new goog.proto2.FieldDescriptor (..../node_modules/google-libphonenumber/dist/libphonenumber.js:1553:16)
at Function.goog.proto2.Message.createDescriptor (..../node_modules/google-libphonenumber/dist/libphonenumber.js:2069:22)
at i18n.phonenumbers.PhoneMetadata.getDescriptor (..../node_modules/google-libphonenumber/dist/libphonenumber.js:2946:117)
at goog.proto2.Message (..../node_modules/google-libphonenumber/dist/libphonenumber.js:1897:23)
at new i18n.phonenumbers.PhoneMetadata (..../node_modules/google-libphonenumber/dist/libphonenumber.js:2411:23)
at Object.<anonymous> (..../node_modules/google-libphonenumber/dist/libphonenumber.js:4432:56)
at Module._compile (module.js:435:26)
the google-libphonenumber version is 1.0.7 (latest) and it doesn't work with older versions either.
Please help!
I am loading a Node.js module using require. This throws a Syntax Error (an Error object).
Is there a way to get the location in the file where the error occurred?
I can see the stack (below) but I don't have any location information. I know I can use substack's node-syntax-error, but is there a way to get similar location info from the Javascript Error object?
SyntaxError: Unexpected identifier
at Module._compile (module.js:437:25)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
... // the rest is in my code
EDIT:
According to Vadim's comment below, yes that is what I am tempted to do. I see that node throws nice errors. Having a test.js file that contains only abc you get an error from node saying
ReferenceError: abc is not defined
at Object.<anonymous> (test.js:1:63)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Now the question is, is there a node API to do get this error (that the node module.js module uses) such that I don't have to child_process.spawn('node', ['test.js'])?
You can simple run node with file that contains SyntaxError and see console output.
Error.stack
Errors have a "stack" property that stores the stack trace.
try {
throw new Error("with some message");
}
catch(err) {
// print error's stack trace to stder
console.error(err.stack);
}
running this on a file called "/home/myusername/test.js"
node /home/myusername/test.js
will output the following
Error: with some message
at Object.<anonymous> (/home/myusername/test.js:2:11)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
#laconbass answer works for me.
err.stack
I tried a blog framework and I got : 500 Internal Server Error. Hopefully I put a console :
app.use(function(error, req, res, next) {
res.status(500).render('500');
console.log(error);
});
and I could see the error which was not descriptive:
TypeError: Cannot read property 'replace' of undefined
After several minuts of research I found this answers, So I tried :
app.use(function(error, req, res, next) {
res.status(500).render('500');
console.log(error.stack);
});
and I could see the source point of error : (Object.exports.replace)
TypeError: Cannot read property 'replace' of undefined
at Object.exports.replace (/.../some_folder/node.js-blog-engine/node_modules/swig/lib/filters.js:411:15)
at eval (eval at <anonymous> (/.../some_folder/node.js-blog-engine/node_modules/swig/lib/swig.js:498:13), <anonymous>:41:63)
at Object.exports.each (/.../some_folder/node.js-blog-engine/node_modules/swig/lib/utils.js:45:11)
at eval (eval at <anonymous> (/.../some_folder/node.js-blog-engine/node_modules/swig/lib/swig.js:498:13), <anonymous>:26:10)
at Object.eval [as tpl] (eval at <anonymous> (/.../some_folder/node.js-blog-engine/node_modules/swig/lib/swig.js:498:13), <anonymous>:85:3)
at compiled (/.../some_folder/node.js-blog-engine/node_modules/swig/lib/swig.js:619:18)
at /.../some_folder/node.js-blog-engine/node_modules/swig/lib/swig.js:559:20
at /.../some_folder/node.js-blog-engine/node_modules/swig/lib/swig.js:690:9
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
I know that this is not a syntax error, but could be works to find the location of a javascript/node error.
I am a novice in nodejs.
I hope this helps.
You can use the stacktracey library (note: I'm the author of this library).
It prints nice callstacks along with source code lines, and also parses the SyntaxError output (in Node higher than v4).
For example, when trying to require this file (named test_files/syntax_error.js):
// next line contains a syntax error (not a valid JavaScript)
foo->bar ()
...the pretty printed call stack for the error thrown would be:
at (syntax error) test_files/syntax_error.js:2 foo->bar ()
at it test.js:184 try { require ('./test_files/syntax_error.js') }
at runCallback timers.js:781
at tryOnImmediate timers.js:743
at processImmediate [as _immediat timers.js:714
...where the first line is generated from parsing the raw output from the util.inspect call in Node.
The library also provides the full API access to the contents of a parsed call stack, so you can tune the output to whatever you want.
node is crashing at the following line:
var tcp = require('tcp'),
error text:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'tcp'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (C:\Program Files\nodejs\websocket\websocket.js:11:11)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Module.require (module.js:357:17)
What is the problem? I found the source on the Internet, and the author, and the visitors also can run it...
Try require('net') instead:
$ node
> var tcp = require('tcp');
The 'tcp' module is now called 'net'. Otherwise it should have a similar interface.
> var tcp = require('net');
> $
Others are able to run, may be because they are using Node module when 'tcp' was there...
Now its called 'net', but its all the same thing no need of checking..
If you want to cross check for your more information, here are the links:
1.http://nodejs.org/api/net.html
2.https://github.com/joyent/node/blob/master/lib/net.js