无法让ReactJS在Mac上编译ReactJS JSX

时间:2016-12-07 06:40:54

标签: c# asp.net-mvc macos reactjs .net-core

我正在使用.Net Core App 1.1.0在Mac OSX上开发一个C#ASPNet Core Web应用程序。我引用了React.AspNet(3.0.0)NuGet包,并遵循此ReactJS tutorial。我知道这个教程是有效的,因为我已经设法让一切都在Windows上运行。但是,当在OS​​X上运行时,我得到以下运行时错误

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/js/tutorial.jsx
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HL0UDE81SLFD": An unhandled exception was thrown by the application.
React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.ReactEnvironment ---> React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.JavaScriptEngineFactory ---> React.Exceptions.VroomJsInitialisationException: Failed to initialise VroomJs. This is most likely caused by the native library (libVroomJsNative.so) being out of date or your system lacking a compatible version of V8. Please run Mono with the `MONO_LOG_LEVEL=debug` environment variable for more debugging information, and refer to the ReactJS.NET Mono documentation at http://reactjs.net/guides/mono.html for further debugging hints.

 More details: Exception has been thrown by the target of an invocation.
   at React.JavaScriptEngineUtils.EnsureEngineFunctional[TEngine,TException](Func`2 exceptionFactory)
   at React.JavaScriptEngineFactory.GetFactory(JsEngineSwitcher jsEngineSwitcher, Boolean allowMsie)
   at React.JavaScriptEngineFactory..ctor(JsEngineSwitcher jsEngineSwitcher, IReactSiteConfiguration config, IFileSystem fileSystem)
   at lambda_method(Closure , Object[] )
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   --- End of inner exception stack trace ---
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   --- End of inner exception stack trace ---
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.CustomObjectLifetimeFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.Resolve[ResolveType]()
   at React.AspNet.BabelFileMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1.<RequestProcessingAsync>d__2.MoveNext()
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 11.2943ms 200

我已经到了想法不足的地步。有人可以帮忙吗?

由于

保罗。

1 个答案:

答案 0 :(得分:1)

遵循关于此Github问题的建议评论(#338)。我可以通过运行以下命令在我自己的项目中解决这个问题:

dotnet add package JavaScriptEngineSwitcher.ChakraCore && dotnet add package JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64