Vscode: [ts] Cannot find module '@angular/core'

Created on 20 Sep 2017  Â·  21Comments  Â·  Source: microsoft/vscode

  • VSCode Version: Code - Insiders 1.17.0-insider (f7962f0682a76516df51de4856f8ccc5d8ad578a, 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~

typescript upstream

Most helpful comment

I can verify this issue.

All 21 comments

I can verify this issue.

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

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, that didn’t help for me. In fact, packages cannot be built using [email protected].

@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]?

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

Hey @mhegazy / @RyanCavanaugh, should we move this over to the TS repo? The issue sounds similar to https://github.com/Microsoft/TypeScript/issues/18630

@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.

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.

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?

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.

Thanks @andy-ms!

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

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

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

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?

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

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 🎉

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.

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.

@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).

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sirius1024 picture sirius1024  Â·  3Comments

v-pavanp picture v-pavanp  Â·  3Comments

shanalikhan picture shanalikhan  Â·  3Comments

chrisdias picture chrisdias  Â·  3Comments

omidgolparvar picture omidgolparvar  Â·  3Comments