簡體   English   中英

Karma TypeScript PreProcessor引發錯誤找不到模塊“角度”

[英]Karma TypeScript PreProcessor throws Error Cannot find module 'angular'

這是我的業力配置

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine', 'traceur'],

    files: [
      'app/**/**/httpMock/httpMock.interceptor.ts',
        'app/**/**/httpMock/httpMock.module.ts',
        'app/**/**/httpMock/httpMock.service.ts',
        'app/**/**/httpMock/httpMock.config.ts'
         ],
     exclude: [
        'modules/**/e2e_test/**',
        'app/**/e2e/**/*.js',
        'thirdparty/pioneer/featureFlag/**/*{t,T}est.js'
    ],

    preprocessors: {
        //'app/**/*.js': ['traceur'],
        '**/*.ts': ['typescript']
    },
    typescriptPreprocessor: {
        options: {
            sourceMap: false,
            target: 'ES5',
            module: 'commonjs',
            noImplicitAny: true,
            noResolve: true,
            removeComments: true,
            concatinateOutput: false
        },
        typings: [ 'typings/tsd.d.ts' ],
        transformPath: function (path) {
            return path.replace(/\.ts$/, '.js');
        }
    },
    browsers: ['Chrome'],
    reporters: ['spec', 'junit'],
    specReporter: { maxLogLines: 5 },
    junitReporter: {
        outputFile: './build/work/jasmine/TEST-results.xml',
        suite: 'COMP'
    },
    port: 9876
});
};

我在package.Json中安裝了dev依賴項,並安裝了預處理器插件。

這是包裹。傑森

"angular": "^1.3.5",
"definitely-typed-angular": "^1.0.1",
"karma": "^0.13.7",
"karma-chrome-launcher": "^0.1.4",
"karma-cli": "^0.0.4",
"karma-dart": "^0.2.8",
"karma-jasmine": "^0.2.2",
"karma-junit-reporter": "^0.2.2",
"karma-spec-reporter": "0.0.16",
"karma-traceur-preprocessor": "^0.4.0",
"karma-typescript-preprocessor": "0.0.20",

運行測試任務運行程序時,我不確定是什么原因導致了問題。

 13 10 2015 10:19:50.276:ERROR [preprocessor.typescript]: Cannot find module 'angular' and namespace 'ng'.

   at C:/*****.ts

對於所有四個文件。 誰能指出出什么問題了?

您需要在plugins:[]提及業力預處理器plugins:[]

config.set({
    frameworks: ['jasmine', 'traceur'],
    ...

    preprocessors: {       
        '**/*.ts': ['typescript']
    },
    plugins: [
        // these are all I am using
        "teamcity",
        "karma-jasmine",

        "karma-sourcemap-loader",

        "karma-junit-reporter",
        "karma-teamcity-reporter",

        "karma-chrome-launcher",
        "karma-phantomjs-launcher",

        // HERE we mention our guilty one
        "karma-typescript-preprocessor"
    ],
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM