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.
Related
I try making a function that reloads the page for me (WebGL unity engine)
I used the Unity site itself: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html to create javescript code
Assets/Plugins/WebGL/MyPlugin.jslib :
var MyPlugin = {
function reloadPage(){
window.location.reload();
}
};
mergeInto(LibraryManager.library, MyPlugin);
Then I call these functions from my C#
[DllImport("__Internal")]
private static extern void reloadPage();
but now when I try to build the project, gave me this error :
Failed process stderr log:
error: failure to execute js library "D:\NFT Creature Mixer\Project\Creature_Mixer\Assets\Plugins\WebGL\MyPlugin.jslib": SyntaxError: Unexpected identifier,,SyntaxError: Unexpected identifier
at Object.load (eval at globalEval (C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8), <anonymous>:179:14)
at JSify (eval at globalEval (C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8), <anonymous>:87:20)
at D:\NFT Creature Mixer\Project\Creature_Mixer\Assets\Plugins\WebGL\MyPlugin.jslib (C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:221: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)
at run (bootstrap_node.js:394:7)
preprocessed source (you can run a js engine on this to get a clearer error message sometimes):
=============
var MyPlugin = {
function reloadPage(){
window.location.reload();
}
};
mergeInto(LibraryManager.library, MyPlugin);
=============
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: "SyntaxError: Unexpected identifier" | SyntaxError: Unexpected identifier
at Object.load (eval at globalEval (C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8), <anonymous>:179:14)
at JSify (eval at globalEval (C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:105:8), <anonymous>:87:20)
at Object.<anonymous> (C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\src\compiler.js:221: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)
at run (bootstrap_node.js:394:7)
Traceback (most recent call last):
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc.py", line 3063, in <module>
sys.exit(run())
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc.py", line 1780, in run
final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\shared.py", line 2274, in emscripten
emscripten._main(cmdline)
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 2233, in _main
return temp_files.run_and_clean(lambda: main(
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\tools\tempfiles.py", line 93, in run_and_clean
return func()
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 2238, in <lambda>
DEBUG=DEBUG,
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 2164, in main
temp_files=temp_files, DEBUG=DEBUG)
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 86, in emscript
glue, forwarded_data = compiler_glue(metadata, libraries, compiler_engine, temp_files, DEBUG)
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 218, in compiler_glue
glue, forwarded_data = compile_settings(compiler_engine, libraries, temp_files)
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten.py", line 541, in compile_settings
cwd=path_from_root('src'), error_limit=300)
File "C:\Program Files\Unity\Hub\Editor\2020.3.27f1\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/Unity/Hub/Editor/2020.3.27f1/Editor/Data\\Tools\\nodejs\\node.exe', '--stack_size=8192', '--max-old-space-size=4096', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\Emscripten\\src\\compiler.js', 'C:\\Users\\aryan\\AppData\\Local\\Temp\\tmpoqaf40.txt', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Audio.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\case_1174367_workaround.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\case_1179945_workaround.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\case_1187965_workaround.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\case_1208971_workaround.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Cursor.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Eval.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\FileSystem.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Logging.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Profiler.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\SystemInfo.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\UnetWebSocket.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\Video.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebCam.js', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\Editor\\Data\\PlaybackEngines\\WebGLSupport\\BuildTools\\lib\\WebRequest.js', 'D:\\NFT Creature Mixer\\Project\\Creature_Mixer\\Assets\\Web3Unity\\Scripts\\Library\\WebGL\\web3gl.jslib', 'D:\\NFT Creature Mixer\\Project\\Creature_Mixer\\Assets\\Plugins\\WebGL\\MyPlugin.jslib', 'C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.27f1\\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 (int,intptr,bool&)
so stupid my javaScript code was wrong
var MyPlugin = {
reloadPage: function (){
window.location.reload();
}
};
mergeInto(LibraryManager.library, MyPlugin);
I have a following structure
root/Test/runtests.js
root/Test/package.json # npm
root/packages/local/foo/package.json # not npm
root/packages/local/foo/spec/ # root for tests
runtests.js:
var Jasmine = require('jasmine');
var jasmine = new Jasmine();
var spec_files = process.argv[2] + '/**/*Spec.js';
jasmine.loadConfig({
spec_dir: '../',
helpers: [],
spec_files: [
spec_files
],
stopSpecOnExpectationFailure: false,
random: true
});
jasmine.execute();
And I run it from inside root/Test with node runtests.js packages/local/foo/spec. Whatever I try, it keeps failing by trying to parse packages/local/foo/package.json. It's not surprising it fails, because that json file isn't actually valid json and uses /* syntax for block comments, but that's beside the point -- why is it being parsed to begin with? How can it be excluded? I tried using ! syntax in spec_files definition, to no avail. Here is what stacktrace look like
(node:48272) UnhandledPromiseRejectionWarning: SyntaxError: Error parsing root\packages\local\foo\package.json: Unexpected token / in JSON at position 7
at JSON.parse (<anonymous>)
at readPackage (internal/modules/cjs/loader.js:239:25)
at readPackageScope (internal/modules/cjs/loader.js:263:19)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:970:17)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Loader.requireShim [as require_] (root\Test\node_modules\jasmine\lib\loader.js:35:3)
at root\Test\node_modules\jasmine\lib\loader.js:28:12
I'm using jasmine ^3.9.0
I am just learning Unit.js with mocha. I am following the steps at: http://unitjs.com/guide/quickstart.html . I have installed mocha and am running the "example.js" script. The script fails with
$ mocha example.js
0 passing (1ms)
Running the example.js in with -full-trace I get:
$ mocha example.js -full-trace
C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\lib\utils.js:652
throw new Error("cannot resolve path (or pattern) '" + path + "'");
^
Error: cannot resolve path (or pattern) '-t'
at Object.lookupFiles (C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\lib\utils.js:652:15)
at C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:326:30
at Array.forEach (native)
at Object.<anonymous> (C:\Users\rball\AppData\Roaming\npm\node_modules\mocha\bin\_mocha:325:6)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:134:18)
at node.js:961:3
I am running this with cygwin64. and running in the directory: /home/rball/test
the example.js is:
// load Unit.js module
var test = require('../node_modules/unit.js');
// just for example of tested value
var example = 'hello';
// assert that example variable is a string
test.string(example);
// or with Must.js
test.must(example).be.a.string();
// or with assert
The unit.js is in the node_modules directory.
The error in the full trace output is baffling since I am not aware of any path with a "-t" in it.
What am I missing?
Thanks for your help
I think you need an extra '-' in front of '-full-trace'.
Example: '--full-trace'
You set your asserter with 'test.string(example)'. You've already passed it the specified variable type, which would be fine if you were validating the string value, length, etc.
Try this instead:
'test.value(example).isString();'
----or----
'test.value(example).must.be.a.string();'
http://unitjs.com/api/value.html#isString
Currently I am using a webGL based browser implementation code at client end. It is working perfectly. But, I want to use the same code at server end. Yes, this is not browser based, pure javascript code using node-webgl library.
While doing thisI am facing a problem.
new Image() is identified by browser, but at server side I am getting error Image is not defined. Below is the error I have attached. There are also additional two errors I am looking into it.
C:\Users\z003npra\Desktop\node>node exp.js
Status: Using GLEW 1.13.0
Linking ./simple.vert+./simple.frag
------------
Vertex info
-----------
(0) : error C5145: must write to gl_Position
Linking ./raycast.vert+./raycast-color.frag
------------
Vertex info
-----------
(0) : error C5145: must write to gl_Position
undefined:346
gl.tf_img = new Image();
^
ReferenceError: Image is not defined
at initTexture (eval at <anonymous> (C:\Users\z003npra\Desktop\node\exp.js:1
5:9), <anonymous>:346:18)
at volumerc_main (eval at <anonymous> (C:\Users\z003npra\Desktop\node\exp.js
:15:9), <anonymous>:392:2)
at Object.<anonymous> (C:\Users\z003npra\Desktop\node\exp.js:17:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3
I tried another method installing canvas i.e npm install canvas and access it's Image object element: However, I am getting other error, looks like it is not compatible. At start I have defined
var Canvas1 = require('canvas')
, Image = Canvas1.Image;
The error is below,
C:\Users\z003npra\Desktop\node>node exp.js
Status: Using GLEW 1.13.0
Linking ./simple.vert+./simple.frag
------------
Vertex info
-----------
(0) : error C5145: must write to gl_Position
Linking ./raycast.vert+./raycast-color.frag
------------
Vertex info
-----------
(0) : error C5145: must write to gl_Position
C:\Users\z003npra\Desktop\node\node_modules\node-webgl\lib\webgl.js:806
throw new TypeError('Expected texImage2D(number target, number level, numb
er internalformat, number format, number type, Image pixels)');
^
TypeError: Expected texImage2D(number target, number level, number internalforma
t, number format, number type, Image pixels)
at Object.texImage2D (C:\Users\z003npra\Desktop\node\node_modules\node-webgl
\lib\webgl.js:806:13)
at handleLoadedTexture (eval at <anonymous> (C:\Users\z003npra\Desktop\node\
exp.js:15:9), <anonymous>:330:5)
at gl.tf_img.onload (eval at <anonymous> (C:\Users\z003npra\Desktop\node\exp
.js:15:9), <anonymous>:349:3)
at Image.src (C:\Users\z003npra\Desktop\node\node_modules\canvas\lib\image.j
s:30:17)
at initTexture (eval at <anonymous> (C:\Users\z003npra\Desktop\node\exp.js:1
5:9), <anonymous>:351:16)
at volumerc_main (eval at <anonymous> (C:\Users\z003npra\Desktop\node\exp.js
:15:9), <anonymous>:392:2)
at Object.<anonymous> (C:\Users\z003npra\Desktop\node\exp.js:17:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
Any other alternative to imitate the Image type in node-webgl based implementation?
Use Image from node-webgl library: var Image = require("node-webgl").Image;
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.