与VisualStudio的代码如下AngularJs2 official Hero tutorial后,我想在Windows 10调试Angularjs2 + NPM与WebStorm + Chrome Windows版
编码和调试使用WebStorm +镀铬对于这一点,我做了如下;
安装Chrome JetBrains的IDE扩展
阅读WebStorm tutorial后,我可能需要添加
--debug
节点选项。
NPM配置如下。
通过以上设置后,单击运行按钮,然后浏览器之前弹出。
但我的问题是,把getHeroes()
return
0123.方法在hero.service.ts
文件或任何其他地方没有命中的断点。
- 无论
--debug
选项,断点没有命中。 - 在WebStorm中,一段时间后弹出
Connection refused: connect
消息。 - 在WebStorm发生连接错误后,Chrome开发人员控制台显示大量消息;
Failed to load resource: net::ERR_CONNECTION_REFUSED http://localhost:3000/browser-sync/socket.io/?EIO=3&transport=polling&t=LUGJH1h
- 管理员模式没有帮助。
- Chrome扩展程序有端口
63342
。我发现启动日志显示端口5858
并将5858
设置为Chrome扩展。但它没有帮助。
的package.json
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.2.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.2",
"typings":"^1.3.2"
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
BS-config.json
{
"browser": "chrome"
}
控制台登录启动
"C:\Program Files (x86)\JetBrains\WebStorm 2016.2.3\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run-script start
To debug "start" script, make sure %NODE_DEBUG_OPTION% string is specified as the first argument for node command you'd like to debug.
For example:
{ "start": "node %NODE_DEBUG_OPTION% server.js" }
Debugger listening on [::]:5858
> [email protected] start C:\Users\Youngjae\Documents\recognition-web
> tsc && concurrently "npm run tsc:w" "npm run lite"
[0]
[0] > [email protected] tsc:w C:\Users\Youngjae\Documents\recognition-web
[0] > tsc -w
[0]
[1]
[1] > [email protected] lite C:\Users\Youngjae\Documents\recognition-web
[1] > lite-server
[1]
[1] ** browser-sync config **
[1] { injectChanges: false,
[1] files: [ './**/*.{html,htm,css,js}' ],
[1] watchOptions: { ignored: 'node_modules' },
[1] server: { baseDir: './', middleware: [ [Function], [Function] ] },
[1] browser: 'chrome' }
[1] [BS] Access URLs:
[1] -------------------------------------
[1] Local: http://localhost:3000
[1] External: http://192.168.56.1:3000
[1] -------------------------------------
[1] UI: http://localhost:3001
[1] UI External: http://192.168.56.1:3001
[1] -------------------------------------
[1] [BS] Serving files from: ./
[1] [BS] Watching files...
[1] 16.10.05 00:20:58 304 GET /index.html
[1] 16.10.05 00:20:58 304 GET /styles.css
.....
如何设置调试环境?
请注意,WebStorm版本2016.2.3和Chrome 53都是最新版本。
谢谢。我的错。我误解了'npm'也是客户工作的一部分。但是,在js调试器配置中,在启动任务之前添加'npm start'时调试器未激活。它只能在命令提示符下键入'npm start'。这篇文章也指出了类似的经验http://stackoverflow.com/questions/37197866/connection-refused-in-webstorm-npm-debug-configuration#comment62179429_37322417 – Youngjae
'发射前'启动配置需要返回退出代码 - 其他进程正在等待返回码开始。这是“发布前”设计的方式 - 它应该用于在运行主流程之前运行某种预处理。由于'npm start'不会返回退出代码,直到您手动终止它,调试器配置不会启动 – lena
//感谢您的友好解释。现在我完全明白了:) – Youngjae