Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
samuela opened this issue Jan 21, 2019 · 1 comment
Labels
Bug A bug in TypeScript
Milestone

Comments

@samuela
Copy link

samuela commented Jan 21, 2019

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:

@cathrinevaage
Copy link

In my monorepo project, I'm encountering this exact error myself.
However, I find that it only happens when target in compilerOptions is set.
Upon removing the option, the error vanishes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants