加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Grunt Typescript找不到角度核心

发布时间:2020-12-17 06:57:21 所属栏目:安全 来源:网络整理
导读:题 为什么我的Grunt Typescript编译器找不到角度核心? 我想它与路径有关,所以编译器无法在node_modules目录中找到libs. 错误 typescript/add.component.ts(1,25): error TS2307: Cannot find module ‘angular2/core’. 建立 Gruntfile.js任务 typescript:

为什么我的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

>包括angular2
>包括打字稿

文件路径

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']);
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读