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

[ts] Cannot find module '@angular/core' #34681

Closed
lizhuangs opened this issue Sep 20, 2017 · 21 comments
Closed

[ts] Cannot find module '@angular/core' #34681

lizhuangs opened this issue Sep 20, 2017 · 21 comments
Assignees
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@lizhuangs
Copy link

  • VSCode Version: Code - Insiders 1.17.0-insider (f7962f0, 2017-09-20T05:24:33.599Z)
  • OS Version: Windows_NT x64 10.0.15063
  • Extensions:
Extension Author (truncated) Version
project-manager ale 0.21.1
path-intellisense chr 1.4.2
githistory don 0.2.3
EditorConfig Edi 0.10.1
tslint eg2 1.0.7
auto-close-tag for 0.5.0
auto-rename-tag for 0.0.14
beautify Hoo 1.1.1
Angular2 joh 2.7.0
vscode-JS-CSS-HTML-formatter lon 0.2.3
Angular-BeastCode Mik 4.4.1
debugger-for-chrome msj 3.3.0
seti-icons qin 0.1.3
vscode-icons rob 7.13.0
code-settings-sync Sha 2.8.3

when I upgrade the lastest vscode 1.17.0 insiders,
I got the error :[ts] Cannot find module '@angular/core',even though my app can also run.
now I uninstall the 1.17.0 insiders and install 1.16.1 stable version.It works well.
hope for testing well when release new version next time.
Tks.I really like it~

@vscodebot vscodebot bot added the insiders label Sep 20, 2017
@Frikki
Copy link

Frikki commented Sep 20, 2017

I can verify this issue.

@Abdullah-AlAttar
Copy link

I'm having the same issue just after the latest update

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 20, 2017

Can you please try installing [email protected] in your workspace and rebuilding your project with that. I'd like to understand if the TypeScript update may have regressed this

@mjbvz mjbvz added info-needed Issue requires more information from poster typescript Typescript support issues labels Sep 20, 2017
@Frikki
Copy link

Frikki commented Sep 20, 2017

@mjbvz, that didn’t help for me. In fact, packages cannot be built using [email protected].

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 20, 2017

@Frikki I'm just trying to track down the root cause right now. What I want to understand is if you are seeing compile errors with the latest insiders build of TypeScript (2.5.3-insiders.20170919) vs with TypeScript 2.5.2 that we included in VSCode 1.16

Independent of VSCode, do you see new compile errors when running tsc from [email protected] vs tsc from [email protected]?

@NickClark
Copy link

Same issue here. I found that by setting VSCode to use my workspace version (2.5.2), the problem went away.

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 21, 2017

Hey @mhegazy / @RyanCavanaugh, should we move this over to the TS repo? The issue sounds similar to microsoft/TypeScript#18630

@Frikki
Copy link

Frikki commented Sep 21, 2017

@mjbvz

Independent of VSCode, do you see new compile errors when running tsc from [email protected] vs tsc from [email protected]?

Yes, I see compilation errors when running tsc using [email protected], but not with [email protected]. Both display errors in VSCode version 1.17.0-insider, however.

@Frikki
Copy link

Frikki commented Sep 21, 2017

Workaround

  1. Open a TypeScript file.
  2. Click the TypeScript version to the bottom right in the Status Bar.
  3. Choose Use Workspace Version from the message box.

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 21, 2017

Thank, yes switching the workspace to use a stable TS version like 2.5.2 is the proper workaround

@mhegazy / @RyanCavanaugh It sounds like users are seeing this on the 2.5.3 insiders but not on 2.5.2. Does that still sound consistent with microsoft/TypeScript#18630 which seems to track a regression that first appeared in TS 2.5?

@ghost
Copy link

ghost commented Sep 22, 2017

This is working on me with typescript@next on the command line (except that @angular/core has some compiler diagnostics relating to microsoft/TypeScript#15104) and in vscode with typescript.tsdk set. It doesn't work without typescript.tsdk, because then vscode uses TypeScript 2.5.3-insiders.20170919, and thus doesn't include microsoft/TypeScript#18651 which was merged less than a day ago.
I've also tested that this works against a local build of the release-2.5 branch of TypeScript.

@ghost ghost mentioned this issue Sep 22, 2017
@mjbvz mjbvz added upstream Issue identified as 'upstream' component related (exists outside of VS Code) and removed info-needed Issue requires more information from poster labels Sep 22, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Sep 22, 2017

Thanks @andy-ms!

Closing as upstream. This should be fixed when we pick up the next TS insiders drop

@smlombardi
Copy link

smlombardi commented Sep 25, 2017

I can't seem to switch versions of Typescript:

screen shot 2017-09-25 at 3 43 20 pm

Note: we have TS 2.5.2 installed, but inside of /client

@ghost
Copy link

ghost commented Sep 25, 2017

@smlombardi Use npm install -g typescript@next, then set up vscode to use it.

@ayyash
Copy link

ayyash commented Sep 27, 2017

When is this going to be fixed? I am stuck with insiders and have no work around, is this going to be fixed soon? Or should I install VSCode for now?

@ghost
Copy link

ghost commented Sep 27, 2017

@ayyash Same advice I gave to @smlombardi -- install typescript@next and get vscode to use that instead of a bundled version

@krzkaczor
Copy link

WORKAROUND FOR DESPERATE ONES

I think I have tried everything that was mentioned across many different issues: reloading projects, using different versions of typescript, playing with type related settings in tsconfig. Nothing seems to work.

Finally, I decided to copy (only for dev since compilation with tsc works without any problems) whole module (it had typings build in) to @types:

cp -r ./node_modules/routing-controllers ./node_modules/@types/routing-controllers

and it works 🎉

@smlombardi
Copy link

FWIW, the advice from @andy-ms worked fine for me. I installed TS 2.5.2 globally, and added
"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib", to my user settings.

@krzkaczor
Copy link

Finally I nailed it down: i was missing "module": "commonjs", setting in package.json. Then suddenly visual studio code started resolving all modules :O really bizarre. I will create a proper bug report if I can reproduce this problem.

@ghost
Copy link

ghost commented Oct 13, 2017

@krzkaczor Without that setting, TypeScript will use a different method to attempt to resolve modules, that doesn't look in node_modules (except for @types packages).

@krzkaczor
Copy link

krzkaczor commented Oct 13, 2017

@andy-ms Yeah you're totally right.

I think I went "full retard" on this one — I was using all the time some weird mix of ts-node with different tools which were happily compiling my project even though running tsc would return errors.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

8 participants