0

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=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)

SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-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.

1
  • 1
    Found this link here, might be worth a try? Commented Sep 18, 2022 at 23:07

1 Answer 1

0

Open your .csproj file for editing, find the following property:

<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>

and change it as follows:

<SpaProxyLaunchCommand>cmd.exe /c npm start</SpaProxyLaunchCommand>

This should work around possible issues with file association for .cmd

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

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.