Build:Cannot find type definition file for 'node'

node.jsasp.net MvcAngular

node.js Problem Overview


VS 2015 community edition (at home), npm 3.10, Angular 2 Im trying to pull get Angular2 setup within an ASP.Net MVC 5 app. The template I started with used an older version of Angular, so I updated the package references.

When I build, the first error in the list is:
Build:Cannot find type definition file for 'node'
There are dozens of other errors after that but Im assuming most are due to this first issue.

Here is the package.json and typings.json

package.json

{
  "version": "1.0.0",
  "name": "aspnet",
  "private": true,
  "scripts": {
    "postinstall": "typings install",
    "typings": "typings"
  },
  "dependencies": {
    "@angular/common": "~4.0.0",
    "@angular/compiler": "~4.0.0",
    "@angular/core": "~4.0.0",
    "@angular/forms": "~4.0.0",
    "@angular/http": "~4.0.0",
    "@angular/platform-browser": "~4.0.0",
    "@angular/platform-browser-dynamic": "~4.0.0",
    "@angular/router": "~4.0.0",
    "angular-in-memory-web-api": "~0.3.0",
    "systemjs": "0.19.40",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "zone.js": "^0.8.4",
    "bootstrap": "^3.3.7"
  },
  "devDependencies": {
    "@types/core-js": "^0.9.41",
    "gulp": "^3.9.1",
    "gulp-clean": "^0.3.2",
    "gulp-concat": "^2.6.1",
    "gulp-tsc": "^1.3.1",
    "gulp-typescript": "^3.1.6",
    "path": "^0.12.7",
    "typescript": "~2.1.0",
    "typings": "~2.1.1"
  }
}

typings.json

{
  "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"
  }
}

If I try to update just the typings, I get these messages

*typings WARN deprecated 11/21/2016: "registry:dt/node#6.0.0+20160909174046" is deprecated (updated, replaced or removed)
typings WARN deprecated 9/14/2016: "registry:dt/core-js#0.0.0+20160725163759" is deprecated (updated, replaced or removed)
typings WARN deprecated 10/25/2016: "registry:dt/jasmine#2.2.0+20160621224255" is deprecated (updated, replaced or removed)*

[ update ]
cleaning out my node_modules folder, then running npm install again cleared things up. This seems to happen most often when I move a project folder to another location on my system.

node.js Solutions


Solution 1 - node.js

In my case, I solved my problem. Hopefully it helps some else later.

npm install @types/node --save-dev

Solution 2 - node.js

I had several problems updating packages through visual studio. From now i always update or add packages with the powershell console.

Start PowerShell and navigate to the folder where package.json is located and then run npm install Restart visual studio after the installation is done.

You can also try to delete your node_modules folder then run npm install

Hope this will solve your problems.

Solution 3 - node.js

Restarting or reloading my VSCode worked

Solution 4 - node.js

For local Visual Studio

If you're starting with a clean template the build in VS functionality should probably work!

Go to Dependencies > npm > Right Click > Restore Packages

Then try build again.

For Visual Studio Team Services
  • Install node https://nodejs.org/en/download/

  • Restart your agent service (VSTS Agent) if not using hosted agents

  • Add a build task to run npm install

  • Click the menu icon next to 'Working folder' to choose the location where your project.json file is located.

    enter code here

Solution 5 - node.js

sometimes its just because some package(s) are missing. you can try running yarn install or npm install should resolve.

Solution 6 - node.js

Problem can be around other issues as well

Try one of the step of the solution posted here https://stackoverflow.com/questions/41834391/cannot-find-type-definition-file-for-node/59854173#59854173 by me

Solution 7 - node.js

The easiest way to go around this in vscode is.

create a .vscode directory, then inside it, create settings.json and put the below json and you are good to go.

{
"search.exclude": {
  "**/node_modules": true
},
"files.watcherExclude": {
  "**/.git/objects/**": true,
  "**/.git/subtree-cache/**": true,
  "**/node_modules/**": true,
  "env-*": true
},
"files.exclude": {
  "**/.git": true,
  "**/.DS_Store": true,
  "**/node_modules": true,
  "env*": true
}
}

Solution 8 - node.js

I had this problem when i've been working with RN and i put a incorrect dependency on my package.

    "@types/": "react-navigation/native",

react-navigation/native don't exists

jsonenter image description here

When i tried run tsc with it, i got this

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbitshiftView Question on Stackoverflow
Solution 1 - node.jsM2012View Answer on Stackoverflow
Solution 2 - node.jsargooView Answer on Stackoverflow
Solution 3 - node.jsAlbertView Answer on Stackoverflow
Solution 4 - node.jsSimon_WeaverView Answer on Stackoverflow
Solution 5 - node.jsaatif shaikhView Answer on Stackoverflow
Solution 6 - node.jsTARJUView Answer on Stackoverflow
Solution 7 - node.jsSodruldeen MustaphaView Answer on Stackoverflow
Solution 8 - node.jsJackson SmithView Answer on Stackoverflow