--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/