简体   繁体   English

调试node.js应用程序时,chrome dev工具“保存”不起作用

[英]chrome dev tools “save” not working while debugging node.js app

While debugging node.js cli script in chrome dev tools (that is possible http://youtu.be/03qGA-GJXjI ), I cannot save the changes I made on the fly like I can when I debug normal javascript from a website. 在chrome dev工具中调试node.js cli脚本时(可能是http://youtu.be/03qGA-GJXjI ),我无法保存我在运行时所做的更改,就像我从网站调试普通的javascript一样。 I get an error message: 我收到一条错误消息:

"Debugger.setScriptSource failed. LiveEdit Failure: Failed to compile new version of script: SyntaxError: Unexpected token [" “Debugger.setScriptSource失败.LiveEdit失败:无法编译新版本的脚本:SyntaxError:意外的令牌[”

And then a warning: 然后警告:

Saving of live-edit changes back to source files is disabled by configuration. 通过配置禁用将实时编辑更改保存回源文件。 Change the option "saveLiveEdit" in config.json to enable this feature. 更改config.json中的选项“saveLiveEdit”以启用此功能。

Does anyone know how to fix this? 有谁知道如何解决这一问题? It would be really convenient to debug and edit file and save it while not leaving chrome dev tools. 在不离开chrome dev工具的情况下调试和编辑文件并保存它会非常方便。

Thanks. 谢谢。

btw, this is how the config.json looks like, https://github.com/node-inspector/node-inspector/blob/master/config.json . 顺便说一句,这就是config.json的样子, https://github.com/node-inspector/node-inspector/blob/master/config.json I tried changing "saveLiveEdit" option to true, but still I get the same message "Saving of live-edit changes back to source files is disabled by configuration. Change the option "saveLiveEdit" in config.json to enable this feature." 我尝试将“saveLiveEdit”选项更改为true,但仍然收到相同的消息“通过配置禁用将实时编辑更改保存回源文件。在config.json中更改选项”saveLiveEdit“以启用此功能。”

This seemed to work for me. 这似乎对我有用。 I started 2 shells: 我开始2炮弹:

  1. node-inspector --save-live-edit node-inspector --save-live-edit
  2. node --debug app.js node --debug app.js

Then go to http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 on your browser. 然后在浏览器中访问http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858

Making changes to your code should save it on the hard drive. 更改代码应将其保存在硬盘驱动器上。

You can use the environment variable node-inspector_save-live-edit and set it to true . 您可以使用环境变量node-inspector_save-live-edit并将其设置为true The environment variable node-inspector_ prefix is scanned by node-inspector. node-inspector_器扫描环境变量node-inspector_前缀。

You can also use $HOME/.node-inspectorrc and store the following: 您还可以使用$ HOME / .node-inspectorrc并存储以下内容:

{ "save-live-edit": true, "preload": false, "hidden": ["node_modules/" ], "nodejs": ["--harmony"] }

Do not modify config.json , changes $YOUR_NPM_PATH\\node_modules\\node-\\lib\\config.js instead. 不要修改config.json ,而是更改$ YOUR_NPM_PATH \\ node_modules \\ node- \\ lib \\ config.js。 Find and modify within the file: 在文件中查找和修改:

'save-live-edit': {
    ...
    ...
    default: true
  },

Use the option --save-live-edit when launching node-debug. 启动node-debug时,请使用选项--save-live-edit

For example: 例如:

node-debug --save-live-edit app.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM