Repro showing that hot reload doesn't work in this case.
-
In a powershell terminal go to the directory containing the file
ReactApp.sln. -
Then execute
dotnet restore -
Go to subdirectory
ClientAppand executenpm ciDo no use npm install to avoid changingpackage-lock.json. -
Open the solution in Visual Studio 2019 Community Edition, version 16.4.2
-
When starting the ReactApp project, everything is fine, except that hot reload doesn't work in our dev environment.
-
Changing a file like
ClientApp/src/components/Home.jsis reflected when reloading the page manually in the browser. -
However, it appears as if the development service is not started properly or at all, so hot reload doesn't work.
-
In the powershell terminal mentioned above, run the command
npm run start -
Now, modifying a file like
ClientApp/src/components/Home.jscauses hot reload
The code base in this repo was created as follows:
-
Install template:
dotnet new -install "Microsoft.AspNetCore.SpaTemplates::*" -
Create directory
ReactApp -
Within directory
ReactApprundotnet new react -
Within directory
ClientAppupdate all npm depencencies to latest stable (as of writing) -
Execute
npm audit fixto ensure all vulnerabilities are resolved -
This updates all react related npm packages as well. Perhaps this requires a change in the SpaServices.Extensions for React.
It appears as if the hypothesis is confirmed by others, see ASP.NET Core issue 17618.
One workaround is disabling the use of IIS for debugging in the project file.
- Visual Studio 2019 Community Edition, version 16.4.2
- Nodejs version 12.13.1
- .NET Core 3.1
Output of dotnet --info:
.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.100\
Host (useful for support):
Version: 3.1.0
Commit: 65f04fb6db
.NET Core SDKs installed:
3.1.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
There seems to be a problem with npm ci in some versions of npm, e.g. version 6.13.4. As a workaround use npm ci --no-optional in folder ./ClientApp. For more details about this issue see npm cli issue 558.