node.js - Node.js 检查选项
问题描述
命令行--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
是执行标志的正确方法。
但是,根据文档,该标志似乎只会检查语法错误,并且不会检查超出您的情况发生的错误。
希望这可以帮助!
推荐阅读
- reactjs - 如何创建用户上传头像功能
- python - 使用 python venv 时出现 ValueError
- asp.net - 如何设置 ComponentArt:NavBar 的最大宽度
- reactjs - 将状态和调度放入单独的上下文提供程序是否可以防止不必要的重新渲染?
- azure - 无法使用 Azure AD 和客户端凭据流为特定范围请求 OAuth2 令牌
- json - 动态配置 JSON 解析器的 Datastage 命令
- xslt - XSLT:根据当前上下文读取其他节点的值
- reactjs - react-dates 如何在 next.js 中加载 moment.js 异步
- flutter - Google Firestore 数据在两个不同的 Google 帐户中同时更新
- elasticsearch - 在 windows 中启动 kibana 时解决“无生命连接”的提示