Node.js 检查选项

标签 node.js powershell

--check 命令行选项应该检查(是否有错误)文件而不执行它,但它不起作用。

它工作过一次或两次,但现在情况并非如此,我是否遗漏了某些内容,或者这可能不是正确的语法?

在 Windows 10/PowerShell 上经过测试(具有管理员权限)

--- PowerShell command line
$ > node --check index.js                           // doesn't do anything (no error thrown)
$ > node -c index.js                                // doesn't do anything (no error thrown)
$ > node index.js --check                           // executes the file (prints 'module executed!' and throws a ReferenceError) 
$ > node index.js -c                                // executes the file (prints 'module executed!' and throws a ReferenceError) 
--- index.js file 
console.log( 'module executed!' );

myRefferenceError;                                  // ReferenceError                      

最佳答案

当然,node --check index.js(或)node -c index.js 是执行该标志的正确方法。

但是,根据 documentation ,看起来该标志只会检查语法错误,而不会检查您案例中发生的错误。

希望这有帮助!

关于Node.js 检查选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59854557/

相关文章:

正则表达式 - 使用 "replace"通过捕获组删除内容

node.js - 使 JWT 失效的成本、性能和陷阱

javascript - 两个队列,一个并发1,另一个并发3

javascript - Mongodb 异步等待与 Express

node.js - 我在 for 循环中使用 let 关键字给出 SyntaxError : Unexpected identifier

powershell - 带双引号的参数没有通过 ArgumentList 正确传递给 Scriptblock

javascript - Next tick override functionality does 函数将被调用

sql - 如何格式化 SQL 中的字符串,以便在 Powershell 中正确解释它?

powershell - 我可以为 dot sourcing 命令取别名吗?

wcf - 为 IIS 创建有效的测试 SSL 证书