cannot find module 'angular2/core'

2019-01-30 21:56发布

enter image description here

These red squiggly lines say cannot find module 'angular2/core',cannot find module 'angular2/router',cannot find module 'angular2/http'. I checked other posts in SO but it seems they have no appropriate answer.

I also added a reference to the d.ts files as seen below but still not working. enter image description here

Other posts say that I need to configure something in the tsconfig.json file but I am using Visual Studio and I see no need to use the tscompiler suggested by the angular team because Visual Studio should be able to compile ts files automatically.

Am I missing something?

Is the tsconfig.json still required even if you use Visual Studio?

How do I get rid of these squiggly lines?

Thanks!

(I am using Visual Studio 2015 and latest Typescript engine)

UPDATE: I am not sure what exactly is the npm package manager. But I have a pre-built package.json file that was created when the project was created. I use this file for installing npm packages. enter image description here

14条回答
Explosion°爆炸
2楼-- · 2019-01-30 22:49

This is how I fixed the problem in VS2015 :

  • Open to the project property window
  • Navigate to the TypeScript Build tab
  • Select CommonJS as module system as shown in image below

enter image description here

查看更多
Anthone
3楼-- · 2019-01-30 22:51

I had this problem on installing ionic 2 - i installed all the packages (package.json update) and updated my npm to v3. This solved it.

查看更多
登录 后发表回答