I have a problem very similar to this one, but instead of a command line application, I have a ASP.NET Web API project with an Angular project inside of it, created using a dotnet template ‘angular’ (dotnet new angular --name something
. .NET 6.0.401).
When I run the application with dotnet run
and open localhost:5097 I get a blank page with a message "Launching the SPA proxy…
This page will automatically redirect to https://localhost:44415 when the SPA proxy is ready." The console constantly prints
info: Microsoft.AspNetCore.SpaProxy.SpaProxyMiddleware[0] SPA proxy is not ready. Returning temporary landing page.
over and over again.
When I enter localhost:44415 I get an error in the console that says
fail: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0] Couldn't start the SPA development server with command 'npm start'.
and a notepad window is opened with content
:: Created by npm, please don't edit manually.
@ECHO OFF
SETLOCAL
SET "NODE_EXE=%~dp0node.exe"
IF NOT EXIST "%NODE_EXE%" (
SET "NODE_EXE=node"
)
SET "NPM_CLI_JS=%~dp0node_modulesnpmbinnpm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
SET "NPM_PREFIX_NPM_CLI_JS=%%Fnode_modulesnpmbinnpm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)
"%NODE_EXE%" "%NPM_CLI_JS%" %*
which is understandably the same as the npm.cmd’s content in my node.js directory. The window name is also "npm.cmd".
As mentioned in the thread I attached previously, I removed a file association for .js in windows settings, but it hasn’t changed anything. The last comment there says something about changing the contents of "lb-discover.cmd" file. I don’t think an ASP.NET + Angular project has an analogical file to it.
I suspect it might have something to do with file association in windows, but I can’t change it for .cmd files.
Thanks in advance.
2
Answers
As suggested by @Yitz - this thing worked
Open your .csproj file for editing, find the following property:
and change it as follows:
This should work around possible issues with file association for .cmd