简体   繁体   English

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

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

I am getting strange errors after updating angular, webpack and typescript.更新 angular、webpack 和 typescript 后出现奇怪的错误。 Any idea what I could be missing?知道我可能会错过什么吗?

When I run the app with npm start I get the following errors:当我使用 npm start 运行应用程序时,出现以下错误:

[at-loader] Cannot find type definition file for 'hammerjs'.
[at-loader] Cannot find type definition file for 'node'.
[at-loader] src\app\app.component.ts:26:14
Cannot find name 'require'.
[at-loader] src\app\app.component.ts:30:15
Cannot find name 'require'.

Here are the dependencies:以下是依赖项:

"dependencies": {
"@angular/common": "2.4.4",
"@angular/compiler": "2.4.4",
"@angular/core": "2.4.4",
"@angular/forms": "2.4.4",
"@angular/http": "2.4.4",
"@angular/material": "2.0.0-beta.1",
"@angular/platform-browser": "2.4.4",
"@angular/platform-browser-dynamic": "2.4.4",
"@angular/platform-server": "2.4.4",
"@angular/router": "3.4.4",
"@angularclass/conventions-loader": "^1.0.13",
"@angularclass/hmr": "~1.2.2",
"@angularclass/hmr-loader": "~3.0.2",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.18",
"angular2-jwt": "0.1.28",
"angular2-moment": "1.1.0",
"auth0-lock": "10.10.1",
"bootstrap": "4.0.0-alpha.5",
"cky-meta": "^1.0.2",
"core-js": "^2.4.1",
"hammerjs": "2.0.8",
"http-server": "^0.9.0",
"ie-shim": "^0.1.0",
"intl": "^1.2.5",
"ng2-img-cropper": "0.7.7",
"ng2-page-scroll": "3.2.1",
"ng2-sharebuttons": "1.1.5",
"reflect-metadata": "^0.1.9",
"rxjs": "5.0.3",
"web-animations-js": "2.2.2",
"zone.js": "0.7.6"
   },
      "devDependencies": {
"@angular/compiler-cli": "~2.4.4",
"@types/chai": "3.4.34",
"@types/core-js": "^0.9.35",
"@types/es6-shim": "^0.31.32",
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.5.41",
"@types/node": "^6.0.60",
"@types/protractor": "^4.0.0",
"@types/selenium-webdriver": "2.53.39",
"@types/source-map": "^0.5.0",
"@types/uglify-js": "^2.0.27",
"@types/webpack": "^2.2.2",
"add-asset-html-webpack-plugin": "^1.0.2",
"angular-router-loader": "^0.5.0",
"angular2-template-loader": "^0.6.0",
"assets-webpack-plugin": "^3.5.1",
"awesome-typescript-loader": "~3.0.0-beta.18",
"bootstrap-loader": "2.0.0-beta.19",
"codelyzer": "~2.0.0-beta.4",
"copy-webpack-plugin": "^4.0.0",
"css-loader": "^0.26.0",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"file-loader": "^0.9.0",
"gh-pages": "^0.12.0",
"html-webpack-plugin": "^2.26.0",
"imports-loader": "^0.7.0",
"istanbul-instrumenter-loader": "1.2.0",
"jasmine-core": "^2.5.2",
"json-loader": "^0.5.4",
"karma": "^1.4.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.2.2",
"karma-remap-coverage": "^0.1.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "2.0.1",
"ng2-facebook-sdk": "1.2.0",
"ngc-webpack": "^1.1.2",
"node-sass": "4.3.0",
"npm-run-all": "^4.0.1",
"parse5": "^3.0.1",
"postcss-loader": "1.2.2",
"protractor": "^4.0.14",
"raw-loader": "0.5.1",
"resolve-url-loader": "1.6.1",
"rimraf": "~2.5.4",
"sass-loader": "4.1.1",
"script-ext-html-webpack-plugin": "^1.5.0",
"source-map-loader": "^0.1.6",
"string-replace-loader": "^1.0.5",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5",
"ts-helpers": "1.1.2",
"ts-node": "^2.0.0",
"tslint": "4.3.1",
"typedoc": "^0.5.5",
"typescript": "2.1.5",
"typings": "2.1.0",
"url-loader": "^0.5.7",
"v8-lazy-parse-webpack-plugin": "^0.3.0",
"webpack": "2.2.0",
"webpack-dev-middleware": "^1.9.0",
"webpack-dev-server": "2.2.0",
"webpack-dll-bundles-plugin": "^1.0.0-beta.5",
"webpack-md5-hash": "^0.0.5",
"webpack-merge": "~2.4.0"

}, "engines": { "node": ">= 4.2.1", "npm": ">= 3" } }, "engines": { "node": ">= 4.2.1", "npm": ">= 3" }

Try re-importing the @types/node package by running this in the Package Manager Console in Visual Studio:尝试通过在 Visual Studio 的包管理器控制台中运行来重新导入 @types/node 包:

npm i -D @types/node

If a specific version must be used, you can specify:如果必须使用特定版本,您可以指定:

npm i -D @types/node@6.0.10

That seems more likely to be a problem of versions within the typings.json file.这似乎更可能是typings.json文件中的版本问题。 Can you try the following?您可以尝试以下方法吗?

typings install dt~node --save
typings install dt~core-js --save
typings install dt~hammerjs --save

It could either be a mismatched ts-node version in which updating ts-node should fix it found here or it could be an incorrect tsconfig.json found here它可能是一个不匹配的 ts-node 版本,其中更新 ts-node 应该修复它在这里找到,或者它可能是一个不正确的 tsconfig.json 在这里找到

If these don't work here are some links you may find useful:如果这些不起作用,这里有一些链接,您可能会觉得有用:

https://github.com/shlomiassaf/angular2-modal/issues/213 https://github.com/shlomiassaf/angular2-modal/issues/213

VS2015: "Cannot find type definition" and "File not found" errors VS2015:“找不到类型定义”和“找不到文件”错误

In my case, after doing an npm update I was getting this error.就我而言,在执行 npm update 后,我收到此错误。 It disappeared by restarting my node server :它通过重新启动我的节点服务器消失了:

npm start

You might need to apply multiple solutions to solve this issue!您可能需要应用多种解决方案来解决此问题!

STEP 1第1步

You might need to install missing typings from @types it's already present and still you are getting this error proceed to step 2您可能需要从已经存在的 @types 中安装缺少的类型,但仍然出现此错误,请继续执行第 2 步

STEP 2第2步

If you are using ts-loader you will need to upgrade this如果您使用的是 ts-loader,则需要升级它

STEP 3 (Not applicable to all)第 3 步(并非适用于所有人)

In some cases it's the webpack versioning which causes this error;在某些情况下,导致此错误的是 webpack 版本控制; upgrading to webpack version, ts-node, awesome-typescript-loader etc will solve it for you升级到 webpack 版本,ts-node,awesome-typescript-loader 等会为你解决

STEP 4 (Angular only)第 4 步(仅限 Angular)

If you have used core-js upgrade its version如果你使用过 core-js 升级它的版本

In general solution varies for all however its the node modules version where you will need to play around a bit!一般来说,解决方案因人而异,但是它的节点模块版本您需要稍微玩一下! It's more of hit and try这更像是一次次尝试

All the best!祝一切顺利!

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

相关问题 构建:找不到“节点”的类型定义文件 - Build: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 打字稿错误TS2688:找不到“ .AppleDouble”的类型定义文件 - Typescript error TS2688: Cannot find type definition file for '.AppleDouble'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM