• {boolean}

    process.throwDeprecation 的初始值表明是否在当前的 Node.js 进程上设置了 --throw-deprecation 标志。 process.throwDeprecation 是可变的,因此可以在运行时设置弃用警告是否应该导致错误。 有关更多信息,参见 ['warning' 事件][process_warning]和 [emitWarning() 方法][process_emit_warning] 的文档。

    1. $ node --throw-deprecation -p "process.throwDeprecation"
    2. true
    3. $ node -p "process.throwDeprecation"
    4. undefined
    5. $ node
    6. > process.emitWarning('test', 'DeprecationWarning');
    7. undefined
    8. > (node:26598) DeprecationWarning: test
    9. > process.throwDeprecation = true;
    10. true
    11. > process.emitWarning('test', 'DeprecationWarning');
    12. 抛出:
    13. [DeprecationWarning: test] { name: 'DeprecationWarning' }