cari

Rumah  >  Soal Jawab  >  teks badan

angular.js - webpack+angular2引入awesome-typescript-loader报错

原来用ts-loader是没问题的,但是需要搭配angular2-template-loader,无奈换回awesome-typescript-loader,就报错了,请大家帮忙看下,有事儿直接说就行,在线等。

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/bindCallback.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/bindNodeCallback.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/combineLatest.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/concat.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/defer.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/dom/ajax.d.ts:2:15 
Invalid module name in augmentation, module '../../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/dom/webSocket.d.ts:2:15 
Invalid module name in augmentation, module '../../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/empty.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/forkJoin.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/from.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/fromEvent.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/fromEventPattern.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/fromPromise.d.ts:2:15 
Invalid module name in augmentation, module '../../Observable' cannot be found.

下面是我的tsconfig.json文件

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "experimentalDecorators": true
        // "outDir": ""
    },
    "buildOnSave": false,
    "compileOnSave": false,
    "exclude": [
        "node_modules"
    ],
    "awesomeTypescriptLoaderOptions": {
        "useWebpackText": true
    }
}

下面是我的webpack配置文件:

/**
 * 开发环境webpack配置
 */
const path = require('path');

module.exports = {
    entry: {
        app: './src/main.ts',
    },
    output: {
        path: path.join(__dirname, 'build'),
        filename: '[name].bundle.js'
    },
    resolve: {
        extensions: ['', '.ts', '.js', '.json']
    },
    module: {
        loaders: [
            {
                test: /\.ts$/,
                loaders: ['awesome-typescript-loader', 'angular2-template-loader'],
                exclude: /(node_modules | libs)/
            },
            {
                test: /.less$/,
                loader: 'less',
                exclude: /(node_modules | libs)/
            },
            {
                test: /.html$/,
                loader: 'raw-loader'
            }
        ]
    }
}
过去多啦不再A梦过去多啦不再A梦2744 hari yang lalu754

membalas semua(2)saya akan balas

  • 世界只因有你

    世界只因有你2017-05-15 17:08:11

    Sebab:
    Versi 2.x terbaharu bagi awesome-typescript-loader hanya serasi dengan typescript 2.x versi (versi rasmi semasa hanya sehingga 1.8).


    Penyelesaian:
    Pilihan 1: Tingkatkan skrip taip kepada versi pratonton

    npm i typescript@next --save-dev

    Pilihan 2: Gunakan versi 1.x pemuat skrip yang hebat

    npm i awesome-typescript-loader@1.1.1 --save-dev
    

    balas
    0
  • 高洛峰

    高洛峰2017-05-15 17:08:11

    Penyelesaian telah ditemui Anda perlu mengemas kini skrip taip kepada versi terkini.

    npm install typescript@next --save-dev

    Rujukan:
    https://github.com/s-panferov/awesome-typescript-loader/issues/179

    balas
    0
  • Batalbalas