320*_*ser 12 c# angular asp.net-core-6.0 visual-studio-2022
我正在尝试使用 Angular 模板创建 ASP.NET Core 6,我使用的是 VS 2022 和 .net 6,npm 是最新版本,Node js 也是如此。
我遵循了正常的项目步骤: 1- 创建一个项目。2- ASP.NET Core 与角度。3-然后在最新的一步中我选择了Framework作为.NET 0.0(长期支持)
认证类型为个人账户。
4-然后我编辑连接字符串以匹配我的数据库连接字符串。
但问题是,当我开始运行该项目时,它会打开一个新的浏览器,如下面的屏幕截图所示,带有两个命令:
我在 cmd 中看到以下错误:
Couldn't start the SPA development server with the command 'npm start'.
Run Code Online (Sandbox Code Playgroud)
请注意,我尝试了以下链接中建议的解决方案,但没有成功:
320*_*ser 10
让我回答我的问题:首先,您必须检查以下参考资料:
1-由 AngularFix 社区管理员测试。2- GitHub 讨论
就我而言,问题出在package.json内的路径中,因此问题与角度文件有关。正是在下面几行中:
"ng": "ng",
"prestart": "node aspnetcore-https",
"start": "run-script-os",
"start:windows": "ng serve --port 44478 --ssl --ssl-cert C://Users//\"My LAPTOP\"//AppData//Roaming//ASP.NET//https//theproject.pem --ssl-key C://Users//\"My LAPTOP\"//AppData//Roaming//ASP.NET//https//theproject.key",
"start:default": "ng serve --port 44478 --ssl --ssl-cert $HOME/.aspnet/https/${npm_package_name}.pem --ssl-key $HOME/.aspnet/https/${npm_package_name}.key",
"build": "ng build",
"build:ssr": "ng run TheProject:server:dev",
"watch": "ng build --watch --configuration development",
"test": "ng test"
}
Run Code Online (Sandbox Code Playgroud)
正好在下面两行:
"start:windows": "ng serve --port 44478 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key",
"start:default": "ng serve --port 44478 --ssl --ssl-cert $HOME/.aspnet/https/${npm_package_name}.pem --ssl-key $HOME/.aspnet/https/${npm_package_name}.key",
Run Code Online (Sandbox Code Playgroud)
检查我的计算机的路径后,我将其更改为以下路径,并将 \ 更改为 // 并且它在我这边工作正常
"start:windows": "ng serve --port 44478 --ssl --ssl-cert C://Users//\"My LAPTOP\"//AppData//Roaming//ASP.NET//https//theproject.pem --ssl-key C://Users//\"My LAPTOP\"//AppData//Roaming//ASP.NET//https//theproject.key",
"start:default": "ng serve --port 44478 --ssl --ssl-cert C://Users//\"My LAPTOP\"//AppData//Roaming//ASP.NET//https//theproject.pem --ssl-key C://Users//\"My LAPTOP\"//AppData//Roaming//ASP.NET//https//theproject.key",
Run Code Online (Sandbox Code Playgroud)
注意:仅当 SPA 页面上显示的端口号与 package.json 文件中存在的端口号匹配时,模板才会自动将您重定向到主页。
| 归档时间: |
|
| 查看次数: |
18147 次 |
| 最近记录: |