Skip to content

Error when using npm linked dependency #134

Closed
@frederikschubert

Description

@frederikschubert

When trying to import a module from a dependency that is linked by npm, the typescript compiler fails to load that file. I don't know if this is a typescript issue or a ts-loader issue.

My setup:
The project named project below in the stacktrace depends on my-dependency. Now when I install my-dependency via npm install my-dependency everything works fine.
But because I want to work on both projects at the same time I link my-dependency via npm link ../my-dependency. This creates the correct symlinks but when I try to bundle my project with webpack the following error is thrown.
This error does not appear if I copy the whole my-dependency directory to my project's node_modules directory.

ts-loader version: 0.7.2
typescript version: 1.7.5
webpack version: 1.12.9

Note: I already used the fix that is suggested in the webpack documentation. It resolved the issues with requiring the loader itself but the issue below remains. Even though the file that the Compiler can't find exists.

Stacktrace:

/Users/user/project/node_modules/typescript/lib/typescript.js:44463
                throw new Error("Could not find file: '" + fileName + "'.");
                ^

Error: Could not find file: '/Users/user/project/node_modules/my-dependency/src/menu-item/index.ts'.
    at getValidSourceFile (/Users/user/project/node_modules/typescript/lib/typescript.js:44463:23)
    at Object.getSyntacticDiagnostics (/Users/user/project/node_modules/typescript/lib/typescript.js:44633:52)
    at /Users/user/project/node_modules/ts-loader/index.js:317:42
    at Array.forEach (native)
    at Compiler.<anonymous> (/Users/user/project/node_modules/ts-loader/index.js:316:14)
    at Compiler.next (/Users/user/project/node_modules/tapable/lib/Tapable.js:69:14)
    at Compiler.<anonymous> (/Users/user/project/node_modules/webpack/lib/CachePlugin.js:40:4)
    at Compiler.applyPluginsAsync (/Users/user/project/node_modules/tapable/lib/Tapable.js:71:13)
    at Compiler.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compiler.js:400:9)
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compilation.js:577:13)
    at Compilation.next (/Users/user/project/node_modules/tapable/lib/Tapable.js:67:11)
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/ProgressPlugin.js:69:5)
    at Compilation.applyPluginsAsync (/Users/user/project/node_modules/tapable/lib/Tapable.js:71:13)
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compilation.js:572:10)
    at Compilation.next (/Users/user/project/node_modules/tapable/lib/Tapable.js:67:11)
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/ProgressPlugin.js:65:5)
    at Compilation.applyPluginsAsync (/Users/user/project/node_modules/tapable/lib/Tapable.js:71:13)
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compilation.js:567:9)
    at Compilation.applyPluginsAsync (/Users/user/project/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compilation.js:563:8)
    at Compilation.applyPluginsAsync (/Users/user/project/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.seal (/Users/user/project/node_modules/webpack/lib/Compilation.js:525:7)
    at Compiler.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compiler.js:397:15)
    at /Users/user/project/node_modules/tapable/lib/Tapable.js:103:11
    at Compilation.<anonymous> (/Users/user/project/node_modules/webpack/lib/Compilation.js:445:10)
    at /Users/user/project/node_modules/webpack/lib/Compilation.js:417:12
    at /Users/user/project/node_modules/webpack/lib/Compilation.js:332:10
    at /Users/user/project/node_modules/async/lib/async.js:52:16
    at done (/Users/user/project/node_modules/async/lib/async.js:246:17)
    at /Users/user/project/node_modules/async/lib/async.js:44:16

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions