1
環境角度CLIのユニットテスト - 予期しないトークン 'のconst'
- 角度/ CLI @ 1.0.0 @
- [email protected]
- [email protected]
問題 node_moduleライブラリから関数をインポートするサービスをプロジェクトに追加しました。今、テストを実行しようとすると、次の結果が得られます。
SyntaxError: Unexpected token 'const'
at webpack:///~/print.js/src/js/print.js:4:0 <- src/test.ts:21436
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
SyntaxError: Unexpected token 'const'
at webpack:///~/print.js/src/js/print.js:4:0 <- src/test.ts:21436
サンプルサービスは、私が
ng test --browsers PhantomJS
マイtsconfig.jsonおよびSRC/tsconfig.spec.jsonはターゲットが設定されているを実行したときに、私は、この問題を取得し、この
import {Injectable} from '@angular/core';
import printjs from 'print.js/src';
@Injectable()
export class PrintService {
constructor() {}
testPrint(url: string): void {
printjs(url);
}
}
のように見えますこの問題の最も一般的な原因と思われる 'es5'
私は次のような投稿を読んだことがありますが、これまでに何も見つかっていません。私にできることはほかにありますか?同じ問題を持つ
- SyntaxError: Unexpected token 'const' for testing.es5.js
- https://github.com/angular/angular-cli/issues/5185
私はCLIが、WebPACKのを使用して、あなたよりも非常に同じエラーを取得していない(私はこの質問には6ヶ月ですけど、私は非常に同様の問題に遭遇しました)。 ソリューションを見つけましたか? – Mozgor