我尝试使用npm安装mongodb,并且随之安装了一系列其他必需的软件包,其中一个是require_optional软件包。当我运行我的程序时,我从webpack中得到了这个错误:
WARNING in ./~/require_optional/index.js
Critical dependencies:
63:18-42 the request of a dependency is an expression
71:20-44 the request of a dependency is an expression
78:35-67 the request of a dependency is an expression
@ ./~/require_optional/index.js 63:18-42 71:20-44 78:35-67
以下是引发错误的代码:
var require_optional = function(name, options) {
//unrelated code
try {
// Validate if it's possible to read the module
moduleEntry = require(moduleEntryFile); // line 63
} catch(err) {
// Attempt to resolve in top level package
try {
// Get the module entry file
moduleEntryFile = resolveFrom(process.cwd(), name);
if(moduleEntryFile == null) return undefined;
// Attempt to resolve the module
moduleEntry = require(moduleEntryFile); // line 71
} catch(err) {
if(err.code === 'MODULE_NOT_FOUND') return undefined;
}
}
// Resolve the location of the module's package.json file
var location = find_package_json(require.resolve(moduleEntryFile)); // line 78
//unrelated code
我真的不知道在这种情况下该做什么,因为我没有编写代码而且不知道如何重写代码(如果我应该?)这样它就不会破坏另一个代码require_optional包的一部分,或另一个包。
我应该做什么?