![](/img/trans.png)
[英]Angular grunt build can't find uglifyjs module during distribution build
[英]Grunt Typescript can't find angular core
題
為什么我的Grunt Typescript編譯器找不到角度核心?
我想它與路徑有關,所以編譯器無法在node_modules目錄中找到libs。
錯誤
typescript / add.component.ts(1,25):錯誤TS2307:找不到模塊'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顯示了它從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', experimentalDecorators: true, emitDecoratorMetadata: true, noImplicitAny: false } } } }); grunt.loadNpmTasks('grunt-ts'); grunt.registerTask('default', ['ts']); };
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.