有一些文件的角度错误TS2307,但项目可以正常运行

时间:2019-06-11 02:10:59

标签: javascript angular typescript

我是Angular / TS的新手,但确实有一个运行正常的小型两页项目。它基于this login example。我被卡住了,但有23个错误“无法找到模块'@ angular / core'之类的文件-只能在某些文件中找到。我可以在一个文件中导入此文件,没有错误:

import { Component, OnInit, OnDestroy } from '@angular/core';

但是,在“表兄弟”文件(父文件夹为同级文件)中,出现错误:

import { Component, OnInit } from '@angular/core';

这23个错误更多的是麻烦,而不是实际的问题,但是我非常想摆脱它们。我正在使用VS2017。这是tsconfig文件,如果有帮助的话:

{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "es6",
"typeRoots": [
  "node_modules/@types"
],
"lib": [
  "es2018",
  "dom"
]
}
}

package.json:

{
"name": "MealBooker",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run MealBooker:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "6.1.10",
"@angular/common": "6.1.10",
"@angular/compiler": "6.1.10",
"@angular/core": "6.1.10",
"@angular/forms": "6.1.10",
"@angular/http": "6.1.10",
"@angular/platform-browser": "6.1.10",
"@angular/platform-browser-dynamic": "6.1.10",
"@angular/platform-server": "6.1.10",
"@angular/router": "6.1.10",
"@nguniversal/module-map-ngfactory-loader": "6.0.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.3.1",
"jquery": "3.3.1",
"popper.js": "^1.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.0",
"@angular/cli": "~6.0.0",
"@angular/compiler-cli": "6.1.10",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"typescript": "~2.7.2"
},
"optionalDependencies": {
"node-sass": "^4.9.3",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}

npm install已运行,项目生成并正常运行。 请注意,node_modules不是解决方案的一部分(在解决方案资源管理器中不可见)。我希望避免将其包含在内,因为当必须搜索30,000个文件和3,800个文件夹(!)时,对项目进行简单搜索会变得很疯狂。

0 个答案:

没有答案