问题
I'm currently going through a https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/WEB-103
on setting up Spa apps with Visual Studio on Mac (macOS Sierra, Visual Studio Community 2017).
I've successfully installed angular core, and am currently trying to create a new project based off of one of the installed templates.
I can see two angular templates when I run sudo dotnet new -l
:
MVC ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
When running sudo dotnet new angular
, I keep getting the following error:
Unable to determine the desired template from the input template name: angular.
The following templates partially match the input. Be more specific with the template name and/or language.
Templates Short Name Language Tags
----------------------------------------------------------------------------
MVC ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
Examples:
dotnet new angular
dotnet new angular
dotnet new --help
Is there something in the command I'm missing? Is something with Visual Studio / dotnet configured incorrectly?
回答1:
To install the Single Page Application (SPA) templates, run the following command:
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
Now create any SPA ...
dotnet new angular -o ngApp
cd .\ngApp\
npm install
dotnet restore
dotnet run
回答2:
With .netcore 2.1
dotnet new angular -o my-new-app
cd my-new-app
Now on 2.1 the package.json is inside client app
cd ClientApp
npm install
dotnet restore
dotnet run
来源:https://stackoverflow.com/questions/44831899/creating-a-new-angular-project-on-mac-with-visual-studio