Given I have app written in Angular2 with app.component.ts
and some imports in it:
import {Component} from 'angular2/core';
import {FiltersService} from "./services/filters-service";
import {SearchPipe} from "./pipes/header-pipe";
import {PaginationPipe} from "./pipes/pagination-pipe";
import {Header} from "./components/header/header.component";
import {Pagination} from "./components/pagination/pagination.component";
import {ConfigService} from "./services/config-service";
import {ResourceService} from "./services/resource-service";
import {HttpService} from "./services/http-service";
import 'rxjs/add/operator/map';
import {GlobalSearch} from "./components/global-search/global-search.component";
import {GlobalSearchPipe} from "./pipes/global-search-pipe";
import {CsvExport} from "./components/dropdown/csv-export.component";
import {HTTP_PROVIDERS} from "angular2/http";
When I start app by npm start
, the app is starting and works properly, but in the console I am getting:
app/app.component.ts(1,25): error TS2307: Cannot find module 'angular2/core'.
app/app.component.ts(18,30): error TS2307: Cannot find module 'angular2/http'.
In fact, there are two parts here:
The compilation part that relies on typings (d.ts files). If these files can't be found for the definition of objects / classes used, you will have compilation error. This won't stop the compilation process. See this question for more details: No compilation error without d.ts files .
The runtime part that relies on JavaScript files. If corresponding files are included or available through the module manager, you will be able to use them.
In your case, I think that you can reach the core.d.ts
file during compilation. When you configure your compiler with the value node
for the moduleResolution
property , it will (tsc) look for it within the node_modules
folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.