无法通过在 Angular 8 项目的 Visual Studio 代码中启动使 Chrome 调试器工作
Unable to get the Chrome debugger to work via launch in Visual Studio Code for an Angular 8 project
将 Angular 升级到版本 8 后,我现在无法在 Visual Studio 代码中 运行 Chrome 调试器。
我没有更改我的 launch.json 类似于以下内容:
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome (https)",
"url": "https://myhost.domain.com:4200",
"webRoot": "${workspaceFolder}"
},
我通过以下命令启动 Angular 应用程序
ng serve --host myhost.domain.com --ssl --disableHostCheck
这在升级之前工作了很长时间。我能够启动 Chrome 并调试 Angular 中的不同组件。现在它所做的只是声明 "Unverified Breakpoint"
我尝试了以下方法:
正在将 webRoot 文件夹位置更改为不同的可能位置。当我为应用程序提供服务时,我确实注意到输出中有一条新消息。 (https://myhost.domain.com:4200/webpack-dev-server/
ℹ“wds”:webpack 输出来自 /
ℹ 「wds」:404s 将退回到 //index.html)
卸载并重新安装 Visual Studio 代码扩展
- 正在添加 SourceMap:true
- 正在使用 ng new test-project 创建一个全新的 Angular 项目并尝试调试该项目,结果相同。
这是我的 package.json 的样子:
{
"name": "my-application",
"version": "0.7.2",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^8.1.1",
"@angular/cdk": "^8.1.0",
"@angular/common": "^8.1.1",
"@angular/compiler": "^8.1.1",
"@angular/core": "^8.1.1",
"@angular/forms": "^8.1.1",
"@angular/material": "^8.1.0",
"@angular/platform-browser": "^8.1.1",
"@angular/platform-browser-dynamic": "^8.1.1",
"@angular/router": "^8.1.1",
"@datorama/akita": "^4.5.0",
"angular-oauth2-oidc": "^5.0.2",
"angular-pipes": "^9.0.2",
"buffer": "^5.2.1",
"chart.js": "^2.8.0",
"core-js": "^3.1.4",
"material-design-icons": "^3.0.1",
"ng2-charts": "^2.3.0",
"rxjs": "~6.5.2",
"speed-measure-webpack-plugin": "^1.3.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.801.1",
"@angular/cli": "^8.1.1",
"@angular/compiler-cli": "^8.1.1",
"@angular/language-service": "^8.1.1",
"@types/jasmine": "~3.3.13",
"@types/jasminewd2": "~2.0.6",
"@types/node": "^12.6.3",
"codelyzer": "^5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.2.0",
"karma-chrome-launcher": "~3.0.0",
"karma-coverage-istanbul-reporter": "~2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "^3.4.5"
}
}
这是 ng 版本的样子:
Angular CLI: 8.1.1
Node: 10.15.0
OS: darwin x64
Angular: 8.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.801.1
@angular-devkit/build-angular 0.801.1
@angular-devkit/build-optimizer 0.801.1
@angular-devkit/build-webpack 0.801.1
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.9
@angular/cdk 8.1.0
@angular/material 8.1.0
@ngtools/webpack 8.1.1
@schematics/angular 8.1.1
@schematics/update 0.801.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.35.2
调试 launch.json
和 tasks.json
配置已针对 Angular 8 更改(均于 2019 年 7 月最近更新)
您可以在 VSCode 文档站点上找到最流行 Debugging Recipes 的链接和详细信息。
Angular 的具体内容在 vscode-recipies GitHub 页面上:
https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI
它们变化太频繁,不值得在此处发布完整配置,所以只需放入链接
将 Angular 升级到版本 8 后,我现在无法在 Visual Studio 代码中 运行 Chrome 调试器。
我没有更改我的 launch.json 类似于以下内容:
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome (https)",
"url": "https://myhost.domain.com:4200",
"webRoot": "${workspaceFolder}"
},
我通过以下命令启动 Angular 应用程序
ng serve --host myhost.domain.com --ssl --disableHostCheck
这在升级之前工作了很长时间。我能够启动 Chrome 并调试 Angular 中的不同组件。现在它所做的只是声明 "Unverified Breakpoint"
我尝试了以下方法:
正在将 webRoot 文件夹位置更改为不同的可能位置。当我为应用程序提供服务时,我确实注意到输出中有一条新消息。 (https://myhost.domain.com:4200/webpack-dev-server/ ℹ“wds”:webpack 输出来自 / ℹ 「wds」:404s 将退回到 //index.html)
卸载并重新安装 Visual Studio 代码扩展
- 正在添加 SourceMap:true
- 正在使用 ng new test-project 创建一个全新的 Angular 项目并尝试调试该项目,结果相同。
这是我的 package.json 的样子:
{
"name": "my-application",
"version": "0.7.2",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^8.1.1",
"@angular/cdk": "^8.1.0",
"@angular/common": "^8.1.1",
"@angular/compiler": "^8.1.1",
"@angular/core": "^8.1.1",
"@angular/forms": "^8.1.1",
"@angular/material": "^8.1.0",
"@angular/platform-browser": "^8.1.1",
"@angular/platform-browser-dynamic": "^8.1.1",
"@angular/router": "^8.1.1",
"@datorama/akita": "^4.5.0",
"angular-oauth2-oidc": "^5.0.2",
"angular-pipes": "^9.0.2",
"buffer": "^5.2.1",
"chart.js": "^2.8.0",
"core-js": "^3.1.4",
"material-design-icons": "^3.0.1",
"ng2-charts": "^2.3.0",
"rxjs": "~6.5.2",
"speed-measure-webpack-plugin": "^1.3.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.801.1",
"@angular/cli": "^8.1.1",
"@angular/compiler-cli": "^8.1.1",
"@angular/language-service": "^8.1.1",
"@types/jasmine": "~3.3.13",
"@types/jasminewd2": "~2.0.6",
"@types/node": "^12.6.3",
"codelyzer": "^5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.2.0",
"karma-chrome-launcher": "~3.0.0",
"karma-coverage-istanbul-reporter": "~2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "^3.4.5"
}
}
这是 ng 版本的样子:
Angular CLI: 8.1.1
Node: 10.15.0
OS: darwin x64
Angular: 8.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.801.1
@angular-devkit/build-angular 0.801.1
@angular-devkit/build-optimizer 0.801.1
@angular-devkit/build-webpack 0.801.1
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.9
@angular/cdk 8.1.0
@angular/material 8.1.0
@ngtools/webpack 8.1.1
@schematics/angular 8.1.1
@schematics/update 0.801.1
rxjs 6.5.2
typescript 3.4.5
webpack 4.35.2
调试 launch.json
和 tasks.json
配置已针对 Angular 8 更改(均于 2019 年 7 月最近更新)
您可以在 VSCode 文档站点上找到最流行 Debugging Recipes 的链接和详细信息。
Angular 的具体内容在 vscode-recipies GitHub 页面上: https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI
它们变化太频繁,不值得在此处发布完整配置,所以只需放入链接