microsoft / microsoft/TypeScript
tsc fails when node_modules is symlinked to a target folder not named node_modules
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with TypeScript 3.3.0-dev.20190119, Yarn, and a node_modules symlink targeting a folder named node_modules_cli rather than node_modules. Start by tracing module resolution for the imports in @oclif/command/lib/*.d.ts; done means compilation succeeds for both relative and absolute symlinks without TS2307 errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100