microsoft / microsoft/TypeScript

tsc fails when node_modules is symlinked to a target folder not named node_modules

Offen
#29,518 1 Kommentar 8 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Domain: Module Resolution
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

TypeScript Version: typescript@3.3.0-dev.20190119

Search Terms: symlink node_modules symbolic link

Code
Consider a project with the following file.

import { Command, flags } from "@oclif/command";
...

In addition the node_modules folder is symlinked to an external folder named ../<path>/node_modules_cli/.

Expected behavior:
The compile to work correctly.

Actual behavior:

$ yarn tsc
yarn run v1.12.3
$ /nu/skainswo/nuvemfs/nuvemfs-cli/node_modules/.bin/tsc
../../../.links/skainswo/node_modules_cli/@oclif/command/lib/command.d.ts:1:25 - error TS2307: Cannot find module '@oclif/config'.

1 import * as Config from '@oclif/config';
                          ~~~~~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@oclif/command/lib/command.d.ts:2:25 - error TS2307: Cannot find module '@oclif/parser'.

2 import * as Parser from '@oclif/parser';
                          ~~~~~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@oclif/command/lib/flags.d.ts:1:25 - error TS2307: Cannot find module '@oclif/config'.

1 import { IConfig } from '@oclif/config';
                          ~~~~~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@oclif/command/lib/flags.d.ts:2:25 - error TS2307: Cannot find module '@oclif/parser'.

2 import * as Parser from '@oclif/parser';
                          ~~~~~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@oclif/command/lib/flags.d.ts:47:34 - error TS2307: Cannot find module '@oclif/parser/lib/flags'.

47 export { boolean, integer } from '@oclif/parser/lib/flags';
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@oclif/command/lib/main.d.ts:1:25 - error TS2307: Cannot find module '@oclif/config'.

1 import * as Config from '@oclif/config';
                          ~~~~~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@types/request/index.d.ts:19:27 - error TS2307: Cannot find module 'caseless'.

19 import caseless = require('caseless');
                             ~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@types/request/index.d.ts:24:27 - error TS2307: Cannot find module 'form-data'.

24 import FormData = require('form-data');
                             ~~~~~~~~~~~

../../../.links/skainswo/node_modules_cli/@types/request/index.d.ts:26:24 - error TS2307: Cannot find module 'tough-cookie'.

26 import tough = require('tough-cookie');
                          ~~~~~~~~~~~~~~


Found 9 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Which makes no sense since the node_modules directory does in fact contain all of the necessary modules.

Moving the destination folder from ../<path>/node_modules_cli/ to ../<path>/node_modules/ fixes everything, and the compile goes through just fine:

$ yarn tsc
yarn run v1.12.3
$ /nu/skainswo/nuvemfs/nuvemfs-cli/node_modules/.bin/tsc
✨  Done in 5.54s.

I've tested and confirmed this behavior with both relative and absolute symbolic links.

Playground Link: n/a

Related Issues:

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere den Fehler mit TypeScript 3.3.0-dev.20190119, Yarn und einem node_modules-Symlink, der auf einen Ordner namens node_modules_cli statt auf node_modules zeigt. Beginne damit, die Modulauflösung für die Importe in @oclif/command/lib/*.d.ts nachzuverfolgen; abgeschlossen ist die Aufgabe, wenn die Kompilierung sowohl für relative als auch für absolute Symlinks ohne TS2307-Fehler erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
node.js, typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.