Question
为什么我的Grunt Typescript编译器找不到角度核心?
我想它与路径有关,所以编译器无法在node_modules目录中找到libs .
Error
typescript / add.component.ts(1,25):错误TS2307:找不到模块'angular2 / core' .
Setup
Gruntfile.js任务
typescript: {
all: {
src: ['typescript/**/*.ts'],
dest: 'javascript/frontend',
options: {
target: "es5",
module: "system",
moduleResolution: "node",
emitDecoratorMetadata: true,
experimentalDecorators: true,
removeComments: false,
noImplicitAny: false
}
}
打字稿/ add.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'mytest',
template: '<h1>test</h1>'
})
export class AppComponent { }
node_modules
-
包括angular2
-
包括打字稿
文件路径
app -- node_modules
-- typescript
-- app.component.ts
-- Gruntfile.js
-- package.json
Used libs/frameworks/tutorials
-
Grunt Typescript Github
-
Angular2 5min Quickstart
1 回答
刚才我遇到了同样的问题 . 以详细模式运行grunt显示了它从grunt配置生成的ts配置文件的内容 . 仔细观察,结果表明,根本没有使用moduleResolution选项 . 但是,另一方面,它没有在官方的grunt-typescript页面上描述 .
无论如何,长话短说:我已经使用了grunt-ts包而且一切都很顺利!为方便起见,我在下面发布了我的配置:-)