Babel.js 部署到Azure Web App时出现ChakraCore.dll异常

qoefvg9y  于 2023-06-04  发布在  Babel
关注(0)|答案(2)|浏览(341)

我有一个应用程序,它使用Babel将一些动态JS转换为es5兼容的JS,以便在IE浏览器中使用。
此设置在本地工作得很好,但是一旦部署到Azure,我在尝试调用

var babel = ReactEnvironment.Current.Babel;

异常触发:

React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.ReactEnvironment (Error getting vue module script) ---> React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.JavaScriptEngineFactory ---> JavaScriptEngineSwitcher.Core.JsEngineLoadException: Failed to create instance of the ChakraCoreJsEngine. Most likely it happened, because the 'ChakraCore.dll' assembly or one of its dependencies was not found. Try to install the JavaScriptEngineSwitcher.ChakraCore.Native.win-x86 package via NuGet. In addition, you still need to install the Microsoft Visual C++ Redistributable for Visual Studio 2017 (https://www.visualstudio.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2017). ---> System.DllNotFoundException: Unable to load DLL 'ChakraCore' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at React.TinyIoC.TinyIoCContainer.ConstructType(System.Type, System.Type, System.Reflection.ConstructorInfo, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
at React.TinyIoC.TinyIoCContainer+CustomObjectLifetimeFactory.GetObject(System.Type, React.TinyIoC.TinyIoCContainer, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
at React.TinyIoC.TinyIoCContainer.ResolveInternal(React.TinyIoC.TinyIoCContainer+TypeRegistration, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
at React.TinyIoC.TinyIoCContainer.Resolve(System.Type)
at React.TinyIoC.TinyIoCContainer.Resolve()
at App.Controllers.ComponentController+<ModuleRegistrationIE11>d__4.MoveNext()
--- End of inner exception stack trace ---
at React.TinyIoC.TinyIoCContainer.ConstructType(System.Type, System.Type, System.Reflection.ConstructorInfo, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
at React.TinyIoC.TinyIoCContainer+SingletonFactory.GetObject(System.Type, React.TinyIoC.TinyIoCContainer, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
at React.TinyIoC.TinyIoCContainer.ResolveInternal(React.TinyIoC.TinyIoCContainer+TypeRegistration, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
at React.TinyIoC.TinyIoCContainer.ConstructType(System.Type, System.Type, System.Reflection.ConstructorInfo, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
--- End of inner exception stack trace ---
at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine..ctor(JavaScriptEngineSwitcher.ChakraCore.ChakraCoreSettings)
at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngineFactory.CreateEngine()
at JSPool.JsPool`2.CreateEngine()
at JSPool.JsPool`2.PopulateEngines()
at JSPool.JsPool`2..ctor()
at React.JavaScriptEngineFactory.CreatePool()
at React.JavaScriptEngineFactory..ctor(JavaScriptEngineSwitcher.Core.IJsEngineSwitcher, React.IReactSiteConfiguration, React.ICache, React.IFileSystem)
at lambda_method(System.Runtime.CompilerServices.Closure, System.Object[])
at React.TinyIoC.TinyIoCContainer.ConstructType(System.Type, System.Type, System.Reflection.ConstructorInfo, React.TinyIoC.NamedParameterOverloads, React.TinyIoC.ResolveOptions)
--- End of inner exception stack trace ---
at JavaScriptEngineSwitcher.ChakraCore.JsRt.NativeMethods.JsCreateRuntime(JavaScriptEngineSwitcher.ChakraCore.JsRt.JsRuntimeAttributes, JavaScriptEngineSwitcher.ChakraCore.JsRt.JsThreadServiceCallback, JavaScriptEngineSwitcher.ChakraCore.JsRt.JsRuntime&)
at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine+<>c__DisplayClass10_1.<.ctor>b__0()
at JavaScriptEngineSwitcher.ChakraCore.ScriptDispatcher+<>c__DisplayClass11_0.<Invoke>b__0()
at JavaScriptEngineSwitcher.ChakraCore.ScriptDispatcher.StartThread()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at JavaScriptEngineSwitcher.ChakraCore.ScriptDispatcher.InnnerInvoke(System.Func`1[[System.Object, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]])
at JavaScriptEngineSwitcher.ChakraCore.ScriptDispatcher.Invoke(System.Action)
at JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine..ctor(JavaScriptEngineSwitcher.ChakraCore.ChakraCoreSettings)

该异常表明ChakraCore.dll很可能丢失,或者Visual Studio 2017的C++可再发行组件丢失。我假设Azure中存在可再发行版本,因为这个https://feedback.azure.com/forums/355860-azure-functions/suggestions/31130971-install-visual-c-2015-or-2017-redistributale
检查Azure

中的文件时,ChakraCore.dll似乎存在
我也尝试了这里的建议,卸载并重新安装所有相关的软件包https://github.com/reactjs/React.NET/issues/400

rks48beu

rks48beu1#

好吧,多亏了一些绝望的尝试和错误,这只是一个关于JavaScriptEngineSwitcher.ChakraCore.Native包添加对其他平台的支持的情况,我最初只有win-x64,但安装win-x86也对它进行了排序,并使其在Azure中工作。
这是我安装的包的最终结果,以使我的应用程序在Azure中成功工作:

<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x86" Version="3.1.1" />
<PackageReference Include="JavaScriptEngineSwitcher.Core" Version="3.1.0" />
<PackageReference Include="JavaScriptEngineSwitcher.Extensions.MsDependencyInjection" Version="3.1.0" />
<PackageReference Include="JSPool" Version="4.0.0" />
uklbhaso

uklbhaso2#

我也遇到了这个问题,在阅读了其他答案后,我意识到这很可能是因为App Service中的配置设置为32位而不是64位。将配置更改为64位后,错误就消失了。我不确定其他人的情况,但对我来说,我没有改变代码,而是让我们的环境符合代码的要求。
1.在Azure门户中导航到Web应用程序
1.单击配置
1.单击顶部的“常规设置”选项卡。
1.在平台下,更改为64位。
1.单击保存(这样做将重新启动应用并应用设置)

相关问题