Skip to content

Typescript Language service not finding symbolic linked (junction) npm module #23502

Closed
@kunlongxu

Description

@kunlongxu

TypeScript Version: 2.8.1
OS Version: macOS 10.13.3
vscode: 1.22.1

Search Terms: npm link

Code

  1. A symbolic link (NTFS junction) to a library package in node_modules breaks code's intellisense ability to find the module, even though building from the command line works fine. This makes node dev a pain when developing a lib and consuming package and don't want to go through the publish / install loop
{
    "compilerOptions": {
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "declaration": true,
        "rootDir": "src", 
        "outDir": "lib",
        "target": "es2015",
        "lib": [
            "dom",
            "es2016"
        ],
        "noImplicitAny": false
    },
  "include": [
    "src/**/*"
  ]
}
  1. Create and compile another package consumer with a file that references the lib with an import {foo} from 'lib'

  2. Copy the lib into the consumer's node_modules - as if it had been `npm install'ed

  3. Look at the import line in code - all intellisense is good. lib is found

  4. Delete node_modules\lib

  5. Either manually link by adding a junction or use npm link ..\lib lib is navigable in the code file browser (on left)

  6. Look at the import line in code - 'lib' has red squiggle and hover displays '[ts] Cannot find module 'lib'.'

I can supply all files if required, but the lib is just a single file with a single export and consuming code references it. basic stuff.

Expected behavior:
ts-server can find npm link module
Actual behavior:
ts-server can not find npm link module
Playground Link:

Related Issues: microsoft/vscode#25312

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions