0
votes

I am using Visual Studio Enterprise 2015 Update 3. I have created a new project "Angular2 Mvc5 sample application" from the Online templates.

When I compile it I got lot of errors like:

Error TS2307 Cannot find module '@angular/core'.

Error TS2307 Cannot find module '@angular/http'.

Error TS2503 Cannot find namespace 'Models'.

What can I do in order to compile it without these errors?

Thanks!

Below is my tsconfig.json file:

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts",
    "Scripts/TypeLite.Net4.d.ts"
  ]
}
1
Did you do npm install? - penleychan
What version of nodejs are you using? - Andre Lombaard
Do you refer at: npm install Angular2? - Cornel Amarandei
I'm using node.js v7.2.0. - Cornel Amarandei
I will assume you did npm install, can you add your tsconfig to your question. - penleychan

1 Answers

0
votes

I create the project with the template you mention. I did not have any luck using "right click package.json and Restore Packages" there was an 404 not found for packages shown in the output.

So instead I did "npm install" via command line, and I was able to compile just fine.

Make sure "node_modules" exists on your directory.

Another thing to note is that the packages are outdated on the package.json.