13

I've created in Visual Studio 2019 a default Angular project with .NET Core 3.0.

When I build the project and run it, I obtain the following error:

error : Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE.

And when the web page starts I obtain exceptions, like in the image at the end of the post.

I know that the error is easy to fix: I need only to download and install Node.js. But I'd like to know why I need to do it, since in the Visual Studio Installer the Node.js option is selected, so it should be already installed. You can see it in my Visual Studio Installer window (sorry, it's in Italian, but you can see Node.js that's already installed anyway).

Is there a way to fix the problem and use the node.js retrieved with Visual Studio installation instead of installing a second one?

Error in web page

node.js selected in Visual Studio Installer

EDIT:

I've found the node.exe executable installed by Visual Studio in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\NodeJs.

I've added the path to External Web Tools in Options->Web Package Management, but the error remains.

External Web Tools

I'm setting the path in the wrong place, or there's something else?

I've also noticed that in the .csproj, it refers to node executable with node instead of node.exe. I've also changed this but with no results.

9
  • Is the path of your node.js install in the external tools search path? (Options | Projects and Solutions | Web Package Management.) Commented Nov 30, 2019 at 11:08
  • Where can I find the path? It's not shown in the installer. Commented Nov 30, 2019 at 11:18
  • When I install node.js it does show the path... which is C:\Program Files\nodejs\node.exe. Commented Nov 30, 2019 at 11:47
  • 1
    I've found node in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\NodeJs. I've added the path where you've said but I've always the same error. Commented Dec 1, 2019 at 9:32
  • It is still saying you need node.js to build the project? Or just the runtime error? Please provide full details of how you are running node at build time (eg. starting with your package.json and details of how you are launching the build of the client side packages. Commented Dec 1, 2019 at 12:03

3 Answers 3

7
error : Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE.

I had the same issue, and it got fixed after I added the install path to Node JS, to the PATH Environment Variable.

I found the Visual studio installation of NodeJS in the following folder (using a simple search for Node.exe) C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJs

Copied the path, opened windows start menu, and searched for "Edit the system environment variables". Clicked the Environment Variables button, and under System variables found the Path variable.

Added the above copied NodeJS path to this variable.

I had to restart Visual Studio once, and I was able to build my solution.

Sign up to request clarification or add additional context in comments.

2 Comments

I did similar, but found the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Node.js script directly from the Node.js Windows installer, added this to the Path variable and my project also compiled. Thanks
Worked perfectly. The visual studio path needs to be changed accordingly to what version of visual studio is installed, in my case I had to change 'Enterprise' with 'Professional'
0

According to Microsoft documentation: Ensure you have an environment variable called ASPNETCORE_ENVIRONMENT with value of Development. On Windows (in non-PowerShell prompts), run SET ASPNETCORE_ENVIRONMENT=Development. On Linux or macOS, run export ASPNETCORE_ENVIRONMENT=Development.

This solved my problem with ASP.NET Core with React project template.

Comments

-2

add this tag in your "yourproject.csproj" file

<Target Name="OptimizeJs">
  <Exec Command=".bin\node Scripts\r.js -o Scripts\build.js" />
</Target>

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.