简体   繁体   English

Nodemon 检查/调试不起作用?

[英]Nodemon inspect/debug not working?

Running nodemon --inspect index.js or nodemon --debug index.js doesn't work.运行nodemon --inspect index.jsnodemon --debug index.js不起作用。

Node Version: 8.9.1节点版本:8.9.1

Nodemon Version: 1.12.6 Nodemon 版本:1.12.6

I have tried these with no luck:我试过这些没有运气:

  • nodemon --inspect-brk index.js

  • nodemon -- --inspect index.js

  • nodemon index.js -- --inspect index.js

  • nodemon index.js -- --debug index.js

  • nodemon -- --debug index.js

  • nodemon --inspect --debug index.js

  • nodemon --debug-brk index.js

But node --inspect index.js or node --inspect-brk index.js works.但是node --inspect index.jsnode --inspect-brk index.js有效。 I wonder how?我想知道怎么做? If any alternatives or some kinda workaround would be great too.如果有任何替代方案或某种解决方法也会很棒。

Please comment if you need further description.如果您需要进一步的描述,请发表评论。

SOLVED ,解决了

It seems like nodemon@1.12.6 was not passing in this argument.似乎nodemon@1.12.6没有传入这个参数。 There is a newer version available 1.12.7 where everything works fine and well.有一个更新的版本1.12.7 ,一切正常。

Answer source: Nodemon Issues - Github答案来源: Nodemon 问题 - Github

For people coming from search engines, there could be a bug related to nodemon and ts-node.对于来自搜索引擎的人来说,可能存在与 nodemon 和 ts-node 相关的错误。

Error: Unknown or unexpected option: --inspect

This can be a way to use inspect with nodemon:这可以是将检查与 nodemon 一起使用的一种方法:

nodemon --exec 'node --inspect=0.0.0.0:9229 --require ts-node/register src/index.ts'

For more information see here有关更多信息,请参见此处

nodemon --inspect app.js

.js 部分是绝对必要的。

FINALLY SOLVED终于解决了

Just follow the below steps are you're good to go:只需按照以下步骤操作即可:

  1. Make sure you have updated version of nodemon.确保您已更新版本的 nodemon。 Update is using following command: npm i nodemon@2.0.4 -g .更新使用以下命令: npm i nodemon@2.0.4 -g Make sure to use -g (to give nodemon permissions to run as an administrator).确保使用-g (授予 nodemon 以管理员身份运行的权限)。 If you get some warnings, try running the same with sudo command sudo npm i nodemon@2.0.4 -g如果您收到一些警告,请尝试使用 sudo 命令运行相同的命令sudo npm i nodemon@2.0.4 -g

  2. Then execute the command as: nodemon --inspect app.js然后执行命令为: nodemon --inspect app.js

I hope it helped..!!我希望它有帮助..!!

As per official doc Nodemon NPM根据官方文档Nodemon NPM

You can also pass the inspect flag to node through the command line as you would normally:您还可以像往常一样通过命令行将检查标志传递给节点:

nodemon --inspect ./server.js 80 nodemon --inspect ./server.js 80

for anyone who is having error ARG_UNKNOWN_OPTION specially with typescript ts-nod and when using auto attach debugger in vscode对于在 typescript ts-nod以及在 vscode 中使用自动附加调试器时出现 ARG_UNKNOWN_OPTION 错误的任何人

example with other arguments like dotenv与其他 arguments 的示例,如 dotenv

nodemon -r dotenv/config./src/index.ts -- --inspect

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

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