题
为什么我的Grunt Typescript编译器找不到角度核心?
我想它与路径有关,所以编译器无法在node_modules目录中找到libs.
typescript/add.component.ts(1,25): error TS2307: Cannot find module ‘angular2/core’.
建立
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
文件路径
app -- node_modules -- typescript -- app.component.ts -- Gruntfile.js -- package.json使用过的libs / frameworks / tutorials
> Grunt Typescript Github
> Angular2 5min Quickstart
解决方法
刚才我遇到了同样的问题.以详细模式运行grunt显示了它从grunt配置生成的ts配置文件的内容.仔细观察,结果表明,根本没有使用moduleResolution选项.但是,另一方面,它没有在官方的grunt-typescript页面上描述.
无论如何,长话短说:我已经使用了grunt-ts包而且一切都很顺利!为方便起见,我在下面发布了我的配置:-)
module.exports = function(grunt) { grunt.initConfig({ ts: { base: { src: ['src/**/*.ts'],dest: 'dist',options: { module: 'system',moduleResolution: 'node',target: 'es5',noImplicitAny: false } } } }); grunt.loadNpmtasks('grunt-ts'); grunt.registerTask('default',['ts']); };
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。