Running in Development Mode
Learn to run React apps in development mode in this chapter.
We'll cover the following...
Steps to run an app in development mode
In the following steps, we’ll examine the ASP.NET Core project file to see what happens when the app runs in development mode:
We can open the project file by right-clicking the web application project in “Solution Explorer” and selecting the “Edit Project File” option:
Press + to interact
This is an XML file that contains information about the Visual Studio project.
Let’s look at the Target element, which has a
Name
attribute ofDebugEnsureNodeEnv
:
Press + to interact
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build"Condition=" '$(Configuration)' == 'Debug' And!Exists('$(SpaRoot)node_modules') "><!-- Ensure Node.js is installed --><Exec Command="node --version"ContinueOnError="true"><Output TaskParameter="ExitCode"PropertyName="ErrorCode" /></Exec><Error Condition="'$(ErrorCode)' != '0'"Text="Node.js is required to build and run thisproject. To continue, please install Node.js fromhttps://nodejs.org/, and then restart yourcommand prompt or IDE."/><Message Importance="high" Text="Restoringdependencies using 'npm'.This may take several minutes..." /><Exec WorkingDirectory="$(SpaRoot)" Command="npminstall" /></Target>
This executes tasks when the ClientApp/node-modules
folder doesn’t exist and the Visual Studio project is run in debug mode, which is the mode that’s used ...