简体   繁体   English

Karma TypeScript PreProcessor引发错误找不到模块“角度”

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

Here is my Karma Config 这是我的业力配置

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

And I have the dev dependencies delcaed in package.Json and the preprocessor plugin installed. 我在package.Json中安装了dev依赖项,并安装了预处理器插件。

Here is the package.Json 这是包裹。杰森

"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",

I am not sure what causing the issue when i run the test task runner says. 运行测试任务运行程序时,我不确定是什么原因导致了问题。

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

   at C:/*****.ts

for all the four files. 对于所有四个文件。 Can anyone point out what is wrong? 谁能指出出什么问题了?

You'd need to mention karma preprocessor in plugins:[] 您需要在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