简体   繁体   English

构建:找不到“节点”的类型定义文件

[英]Build:Cannot find type definition file for 'node'

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. VS 2015 社区版(在家)、npm 3.10、Angular 2 我试图在 ASP.Net MVC 5 应用程序中拉取 Angular2 设置。 The template I started with used an older version of Angular, so I updated the package references.我开始使用的模板使用了旧版本的 Angular,所以我更新了包引用。

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 和typings.json

package.json包.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打字.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.清理我的 node_modules 文件夹,然后再次运行 npm install 清除一切。 This seems to happen most often when I move a project folder to another location on my system.当我将项目文件夹移动到系统上的另一个位置时,这似乎最常发生。

In my case, I solved my problem. 就我而言,我解决了我的问题。 Hopefully it helps some else later. 希望以后能对其他人有所帮助。

npm install @types/node --save-dev

I had several problems updating packages through visual studio. 我在通过Visual Studio更新软件包时遇到了一些问题。 From now i always update or add packages with the powershell console. 从现在开始,我始终使用Powershell控制台更新或添加软件包。

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. 启动PowerShell并导航到package.json所在的文件夹,然后运行npm install完成安装后重新启动visual studio。

You can also try to delete your node_modules folder then run npm install 您也可以尝试删除您的node_modules文件夹,然后运行npm install

Hope this will solve your problems. 希望这能解决您的问题。

重新启动或重新加载我的 VSCode 工作

The easiest way to go around this in vscode is.在 vscode 中解决这个问题的最简单方法是。

create a .vscode directory, then inside it, create settings.json and put the below json and you are good to go.创建一个 .vscode 目录,然后在其中创建 settings.json 并放入下面的 json 就可以了。

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

For local Visual Studio 对于本地Visual Studio

If you're starting with a clean template the build in VS functionality should probably work! 如果您从一个干净的模板开始,则VS功能中的内置功能应该可以工作!

Go to Dependencies > npm > Right Click > Restore Packages 转到Dependencies > npm >右键单击> Restore Packages

Then try build again. 然后尝试再次构建。

For Visual Studio Team Services 对于Visual Studio Team Services

  • Install node https://nodejs.org/en/download/ 安装节点https://nodejs.org/en/download/
  • Restart your agent service (VSTS Agent) if not using hosted agents 如果不使用托管代理,请重新启动代理服务(VSTS代理)
  • Add a build task to run npm install 添加构建任务以运行npm install
  • Click the menu icon next to 'Working folder' to choose the location where your project.json file is located. 单击“工作文件夹”旁边的菜单图标,选择project.json文件所在的位置。

    在这里输入代码

sometimes its just because some package(s) are missing.有时只是因为缺少某些软件包。 you can try running yarn install or npm install should resolve.您可以尝试运行yarn installnpm install应该可以解决。

Problem can be around other issues as well问题也可能与其他问题有关

Try one of the step of the solution posted here Cannot find type definition file for 'node' by me尝试此处发布的解决方案的步骤之一无法找到我的“节点”类型定义文件

I had this problem when i've been working with RN and i put a incorrect dependency on my package.我在使用 RN 时遇到了这个问题,并且我对我的包的依赖不正确。

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

react-navigation/native don't exists反应导航/本机不存在

json json 在此处输入图片说明

When i tried run tsc with it, i got this当我尝试用它运行 tsc 时,我得到了这个

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到“节点”的类型定义文件 - Cannot find type definition file for 'node' npm install => 找不到“节点”的类型定义文件 - npm install => Cannot find type definition file for 'node' TS2688:找不到安装了@ types / node的“ node”的类型定义文件 - TS2688: Cannot find type definition file for 'node' with @types/node installed Elastic Beanstalk“错误 TS2688:找不到‘节点’的类型定义文件。” - Elastic Beanstalk "error TS2688: Cannot find type definition file for 'node'." 找不到'core-js'的类型定义文件 - Cannot find type definition file for 'core-js' “找不到‘async’的类型定义文件。TS2688” - "Cannot find type definition file for 'async'. TS2688" 在 heroku 节点上编译 ts-jest types-找不到类型定义 - Compile on heroku node ts- jest types- cannot find type definition ../node_modules/ng2-ckeditor/ckbutton 中的错误。 指令.d.TS:1:23 - 错误 TS2688:找不到“ckeditor”的类型定义文件 - ERROR in ../node_modules/ng2-ckeditor/ckbutton. directive.d.TS: 1:23 - error TS2688: Cannot find type definition file for 'ckeditor' MongDB找不到Promise类型定义 - MongDB cannot find Promise type definition 每次我尝试部署函数时,我都会收到“找不到类型定义文件...” - Everytime I try to deploy functions I get "Cannot find type definition file for ..."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM