webpack-node-externals icon indicating copy to clipboard operation
webpack-node-externals copied to clipboard

Question about additionalModuleDirs

Open therealgilles opened this issue 4 years ago • 2 comments

I'm looking at the additionalModuleDirs option to specify additional node_modules locations. I observe the code below:

    additionalModuleDirs.forEach(function (additionalDirectory) {
        console.log('...', additionalDirectory, utils.readDir(additionalDirectory).filter(isNotBinary));
        nodeModules = nodeModules.concat(
            utils.readDir(additionalDirectory).filter(isNotBinary)
        );
    });

correctly grab the module names but then what ends up in the bundle is a require('module') without the relative path, so node won't be able to find the module without setting the NODE_PATH env variable to point to the additional node_modules locations. Is that the desired behavior?

therealgilles avatar Jan 02 '21 23:01 therealgilles

@therealgilles is the 'module' originally an absolute request? since then it is what is desired, webpack leaves the 'module' to be handled by nodejs

hulkyhawk avatar Jan 17 '21 06:01 hulkyhawk

@hulkyhawk, not sure exactly what you mean by an absolute request? do you mean an import with an absolute path? If so, no.

therealgilles avatar Jan 18 '21 19:01 therealgilles