极客时间返利平台,你可以在上边通过山月的链接购买课程,并添加我的微信 (shanyue94) 领取返现。
山月训练营之面试直通车 服务上线了,从准备简历、八股文准备、项目经历准备、面试、面经、面经解答、主观问题答复、谈薪再到入职的一条龙服务。

# optionalDependencies 的使用场景是什么

Issue

欢迎在 Gtihub Issue 中回答此问题: Issue 296 (opens new window)

当一个包是可依赖可不依赖时,可采用 optionalDependencies,但需要在代码中做好异常处理。

chokidar (opens new window)fsevents 的引入

{
  "optionalDependencies": {
    "fsevents": "~2.1.2"
  }
}
let fsevents;
try {
  fsevents = require("fsevents");
} catch (error) {
  if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
}
Last Updated: 11/27/2021, 6:11:48 PM