I am trying to create an Angular 2 application using Typescript in Visual Studio 2015. I have installed npm on my machine. When I compile my application , I am getting error
The angular2
name in modules names is for versions before RC (release candidate) versions (beta ones) and the @angular
one for RC versions.
You first need to add typings at global level as below.
npm install -g typings
Then create typings.json using below command.
typings init
Paste below code in typings.json
{
"name": "ng2-application",
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160909174046"
}
}
Now you need to add below code in tsconfig.json
"compilerOptions": {
"moduleResolution": "node"
}
After doing above steps you will able to get definitions on F12.
This will create a node_modules folder within that directory which should have the @angular/core that's required.
When I had this issue, it would come and go depending on the module kind I had selected. (Visual Studio, right-click project, properties, Typescript tab. It would occur for the "System" Module System, which is used in Angular2 QuickStart tutorial, but not for some others, for example.)
I verified the folder /node_modules/@angular/core/ existed in the proj and was populated.
Solution was to edit the .csproj file and add the line <TypeScriptModuleResolution>Node</TypeScriptModuleResolution>
in both Debug and Release sections. VS defaults to Classic for this setting for some settings of ModuleKind.