This question shows research effort; it is useful and clear
2
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
是否可以判断一个模块/包是否可以使用?
像这样的东西:
var moduleexists = require "moduleexists"
if (moduleexists("strangemodule")) {
var strangemodule = require("strangemodule");
strangeModule.doCoolStuff();
} else {
// Do something without strangemodule
}