Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INodeServices IIS Node environment variable not found #12474

Closed
atotalnoob opened this issue May 14, 2019 · 16 comments · Fixed by #16182
Closed

INodeServices IIS Node environment variable not found #12474

atotalnoob opened this issue May 14, 2019 · 16 comments · Fixed by #16182
Assignees
Labels
area-mvc doc-enhancement Pri2 Priority 2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Milestone

Comments

@atotalnoob
Copy link

atotalnoob commented May 14, 2019

Is your feature request related to a problem? Please describe.

I have an ASP.NET Core 2.1 application we recently integrated INodeServices into to run javascript. I installed NodeJS version 10.15.3-x64 onto the server using default installation.

My application runs on IIS 8/Windows Server 2012.

INodeServices worked fine on localhost and passed unit tests, so I pushed it to our unstable dev for further testing. It immediately failed, throwing an exception saying Node was not found in the path environment variable.

I checked the environment variable and it node was present, as well as node --version was working.

Describe the solution you'd like

I resolved this issue by doing this:

Configure Application Pool Identity

a. Right click on the application pool and select advanced settings
b. Under Process Model, set Load User Profile to True.
i. Recycle the application pool, then navigate to the webpage once to trigger the application pool identity creation
c. Note the Application Pool name
d. Open up Regedit
i. Locate HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist, find the identity name noted in C in the data column, located in the path \Device\HarddiskVolume1\Users\ApplicationPoolName

ii. Copy down the name, which should look like \Registry\User\S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236

iii. Locate that user in HKEY_USERS\

  1. DO NOTE SELECT THE USER PROFILE WITH _Classes

iv. Expand the key, find the environment key and select it

v. Under Name column, if there is a variable called PATH already, select it and add C:\Program Files\nodejs\

  1. Otherwise, create a new entry by right clicking and selecting 'Expandable String Value'

  2. Set the name to PATH and the data to C:\Program Files\nodejs\

I would like to have this documented somehwere to assist other developers with this problem.

Describe alternatives you've considered

Additional context

Add any other context or screenshots about the feature request here.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @atotalnoob.
You've actually came up with the right way to handle this.

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/aspnetcore May 20, 2019
@guardrex guardrex added the PU label May 20, 2019
@guardrex guardrex added this to the Backlog milestone May 20, 2019
@mkArtakMSFT
Copy link
Member

@atotalnoob do you plan to turn this into a PR for 2.1 docs? If not, this area got obsoleted (dotnet/aspnetcore#12890) so we will otherwise close this issue.

@atotalnoob
Copy link
Author

atotalnoob commented Sep 5, 2019

No. And this should be documented. 2.1 is a LTS release.

Also, removing nodeservices from .net is dumb

@danroth27
Copy link
Member

And this should be documented. 2.1 is a LTS release.

I think that's reasonable. The doc update here sounds pretty straightforward - we just need to tell people how to get node onto the path when running on IIS.

@scottaddie is this something you could help out with?

@shirhatti could you please confirm that the steps suggested here are the best way to get node on the path for your app?

@danroth27
Copy link
Member

Actually, shouldn't adding node to the system path resolve this issue? IIS apps run under specific locked down user accounts. @atotalnoob Did you try that and it didn't work?

@atotalnoob
Copy link
Author

Putting it on system path did not work for me.

@danroth27
Copy link
Member

@atotalnoob Got it - thx.

@scottaddie We should investigate a bit what's going on here before documenting this. From what I understand using the system path should work. @shirhatti ?

@atotalnoob
Copy link
Author

System path is still not ideal, what if you have multiple versions of node installed?

@shirhatti
Copy link
Contributor

Follow-up to what Dan said, System PATH will work. It mostly likely requires a reboot if didn't work for you.

If you want to change an environment variable on a per ASP.NET Core application in ASP.NET Core you can set it in the web.config. You can use that escape hatch to change the PATH entirely

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
      <environmentVariables>
        <environmentVariable name="PATH" value="..." />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

@atotalnoob
Copy link
Author

I I did reboot multiple times.

I tried setting it in the web.config.

@Rick-Anderson
Copy link
Contributor

@scottaddie what doc does this belong in? Can you add meta-data to create an integrated issue? @wadepickett could add the instructions.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue and removed rerun-labels labels Dec 11, 2019
@scottaddie scottaddie removed their assignment Dec 11, 2019
@scottaddie
Copy link
Member

@wadepickett Go ahead with adding the instructions.

@wadepickett
Copy link
Contributor

@scottaddie, thanks. Rick had asked what doc this belongs in. Is that no longer an open question? Put it in "Use JavaScript Services to Create Single Page Applications in ASP.NET Core" I assume then listed at the top?

Also the "instruction" needed has resolved to simply using shirhatti's instruction of setting the system PATH in the web.config as the solution (and whatever intro to that needed).

@Rick-Anderson Rick-Anderson added the Pri2 Priority 2 label Dec 11, 2019
@scottaddie
Copy link
Member

scottaddie commented Dec 12, 2019

@wadepickett Yes, this goes in the JavaScript Services doc. The most natural place for the instruction is beneath the "Node.js (version 6 or later) with npm" bullet point in the Prerequisites for using SpaServices section. Maybe just add a bullet that says:

To add Node.js to the System PATH environment variable, include the following snippet in *web.config* (IIS only):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
      <environmentVariables>
        <environmentVariable name="PATH" value="..." />
      </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

You might want to move this XML snippet to an external file so you can highlight the <environmentVariable name... line.

@mohamedeg97

This comment has been minimized.

@wadepickett
Copy link
Contributor

wadepickett commented Dec 12, 2019

@mohamedeg97, I think it was fair to verify given atotalnoob indicated it did not fix the particular problem atotalnoob was experiencing, and that Rick had asked what doc this belonged in. You don't think so?

I do agree it is easy and I felt awkward having to verify.

@Rick-Anderson Rick-Anderson added this to To do in Next sprint via automation Dec 13, 2019
@Rick-Anderson Rick-Anderson removed this from To do in Next sprint Dec 13, 2019
@Rick-Anderson Rick-Anderson added this to To do in December 2019 via automation Dec 13, 2019
December 2019 automation moved this from To do to Done Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc doc-enhancement Pri2 Priority 2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
No open projects
December 2019
  
Done
Development

Successfully merging a pull request may close this issue.

10 participants