Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Error: Cannot find module '' when a module name ends with an exclamation mark #8

Open
hashikuchi opened this issue Jul 5, 2018 · 0 comments

Comments

@hashikuchi
Copy link

Error: Cannot find module ''
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._resolveFilename (C:\Development\Platform_unit_test_research\Components\Platform\Client\node_modules\tsconfig-paths\lib\register.js:33:40)
at C:\Development\Platform_unit_test_research\Components\Platform\Client\node_modules\amd-loader\amd-loader.js:56:31
at C:\Development\Platform_unit_test_research\Components\Platform\Client\node_modules\amd-loader\amd-loader.js:80:24

It looks the line 48 of amd-loder.js splits the file name which ends with "!" into two or more strings including an empty string then causes the error.

e.g. "myModule!" -> ["myModule", ""]

    var req = function(module, relativeId, callback) {
    if (Array.isArray(relativeId)) {
        // async require
        return callback.apply(this, relativeId.map(req))
    }
    var chunks = relativeId.split("!"); // Issue happens here?
    var prefix;
    if (chunks.length >= 2) {
        prefix = chunks[0];
        relativeId = chunks.slice(1).join("!");
    }
    var fileName = Module._resolveFilename(relativeId, module);
    if (Array.isArray(fileName))
        fileName = fileName[0];
    
    if (prefix && prefix.indexOf("text") !== -1) {
        return fs.readFileSync(fileName, "utf8");
    } else
        return require(fileName);
}.bind(this, mod);
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant