3

We are using Sitecore JSS running against Sitecore 9.2 in containers. The containers are built from https://github.com/Sitecore/docker-images with only minor changes (adding Unicorn, App Insights etc). We've had the starter app running fine in a separate but similar scenario, and we are now building our own app.

When I start the containers I can see the 'Welcome to Sitecore' page with the woman on the phone and login and use the Experience editor and the Content editor just fine. However, when I try to view the JSS app I get the following error:

Error Rendering Sitecore.JavaScriptServices.ViewEngine.Presentation.JsLayoutRenderer: Item has already been added. Key in dictionary: 'PSMODULEPATH' Key being added: 'PSModulePath'
   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
   at System.Diagnostics.ProcessStartInfo.get_EnvironmentVariables()
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.HostingModels.OutOfProcessNodeInstance.PrepareNodeProcessStartInfo(String entryPointFilename, String projectPath, String commandLineArguments, IDictionary`2 environmentVars, Boolean launchWithDebugging, Int32 debuggingPort)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String entryPointScript, String projectPath, String[] watchFileExtensions, String commandLineArguments, ILogger nodeOutputLogger, IDictionary`2 environmentVars, Int32 invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32 debuggingPort, String nodePath)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.HostingModels.Http.HttpNodeInstance..ctor(NodeServicesOptions options, Int32 port)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.NodeServicesOptions.<.ctor>b__3_0()
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.DefaultNodeServices.GetOrCreateCurrentNodeInstance()
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.DefaultNodeServices.InvokeExportWithPossibleRetry[T](String moduleName, String exportedFunctionName, Object[] args, Boolean allowRetry)
   at Sitecore.JavaScriptServices.ViewEngine.NodeServices.DefaultNodeServices.InvokeExport[T](String moduleName, String exportedFunctionName, Object[] args)
   at Sitecore.JavaScriptServices.ViewEngine.Node.NodeRenderEngine.Invoke[T](String moduleName, String functionName, Object[] functionArgs)
   at Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.PerformRender(TextWriter writer, IRenderEngine renderEngine, String moduleName, String functionName, Object[] functionArgs)
   at Sitecore.JavaScriptServices.ViewEngine.Presentation.JssRenderer.Render(TextWriter writer)
   at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)

This happens on CM and CD, whether logged out or logged in, Experience editor or not. The home page of the JSS app that I'm trying to view is very simple at the moment, just a few components, and removing those doesn't help.

In PowerShell I can see that the PsModulePath environment variable exists, but just once. I tried unsetting it as an experiment but that didn't help.

App_Config\Sitecore\JavaScriptServices\Sitecore.JavaScriptServices.ViewEngine.Node.config does not contain any reference to PSModulePath.

It may be that the PSModulePath key is not important, and it is simply trying to load all environment variables twice.

Any suggestions?

2
  • Did you check out these two articles? I don't know enough about your specific problem to determine if they would be useful, but here you go. kamsar.net/index.php/2019/09/… and kamsar.net/index.php/2019/09/… Mar 11, 2020 at 16:40
  • Yes, we've been using Sitecore in containers for a while experimenting with the demo app and those articles got us started. No help for this though, sadly.
    – sussexrick
    Mar 11, 2020 at 17:14

1 Answer 1

6

This is a known issue with IIS ServiceMonitor, which is used as an entrypoint for Docker images: https://github.com/Microsoft/IIS.ServiceMonitor/issues/32

ServiceMonitor copies environment variables to IIS process on container startup, however it is making them uppercase. This is why you see the error with duplicate PSMODULEPATH entry.

Latest version of ServiceMonitor (2.0.1.9) contains a fix for the issue, however Microsoft base images still use the old version (2.0.1.6). I have created a PR to update the version: https://github.com/microsoft/dotnet-framework-docker/pull/531

Until the PR is accepted, you can do the following:

  1. Download latest version of ServiceMonitor: https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.9/ServiceMonitor.exe

  2. Replace existing exe file C:\ServiceMonitor.exe when building your Docker container

Update (16.04.2020): Microsoft merged the pull request, so you can now pull latest version of Windows server images (just rebuild your Sitecore Docker images) to have this fixed!

1
  • Brilliant, that worked. Thank you!
    – sussexrick
    Mar 13, 2020 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.