question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ng test` fails, is unable to compile TypeScript

See original GitHub issue

OS?

macOS Sierra (10.12.3)

Versions.

@angular/cli: 1.0.0-beta.30 node: 7.5.0 os: darwin x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7

Repro steps.

ng new cool-app cd cool-app ng test

The log given by the failure.

➜ cool-app git:(master) ng test 09 02 2017 19:33:49.134:ERROR [config]: Error in config file! { TSError: ⨯ Unable to compile TypeScript …/…/…/workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/plugin.ts (48,25): Cannot find name ‘Promise’. (2304) …/…/…/workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/plugin.ts (148,43): Property ‘assign’ does not exist on type ‘ObjectConstructor’. (2339) …/…/…/workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/plugin.ts (349,25): Cannot find name ‘Promise’. (2304) at getOutput (/private/tmp/cool-app/node_modules/ts-node/src/index.ts:258:17) at /private/tmp/cool-app/node_modules/ts-node/src/index.ts:267:16 at Object.compile (/private/tmp/cool-app/node_modules/ts-node/src/index.ts:403:17) at loader (/private/tmp/cool-app/node_modules/ts-node/src/index.ts:289:33) at Object.require.extensions.(anonymous function) [as .ts] (/private/tmp/cool-app/node_modules/ts-node/src/index.ts:306:14) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Function.Module._load (workspace/js/ng/angular-cli.git/lib/bootstrap-local.js:69:24) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object.<anonymous> (workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/index.ts:1:1) at Module._compile (module.js:571:32) at loader (/private/tmp/cool-app/node_modules/ts-node/src/index.ts:289:14) at Object.require.extensions.(anonymous function) [as .ts] (/private/tmp/cool-app/node_modules/ts-node/src/index.ts:306:14) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Function.Module._load (workspace/js/ng/angular-cli.git/lib/bootstrap-local.js:56:22) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object.<anonymous> (workspace/js/ng/angular-cli.git/packages/@angular/cli/models/webpack-configs/test.js:5:17) at Module._compile (module.js:571:32) at Object.Module._extensions…js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Function.Module._load (workspace/js/ng/angular-cli.git/lib/bootstrap-local.js:69:24) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object.<anonymous> (workspace/js/ng/angular-cli.git/packages/@angular/cli/plugins/karma.js:4:23) at Module._compile (module.js:571:32) at Object.Module._extensions…js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Function.Module._load (workspace/js/ng/angular-cli.git/lib/bootstrap-local.js:62:22) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at module.exports (/private/tmp/cool-app/karma.conf.js:12:7) at Object.parseConfig (/private/tmp/cool-app/node_modules/karma/lib/config.js:342:5) at new Server (/private/tmp/cool-app/node_modules/karma/lib/server.js:56:20) at /private/tmp/cool-app/node_modules/@angular/cli/tasks/test.js:26:31 at Class.run (/private/tmp/cool-app/node_modules/@angular/cli/tasks/test.js:10:16) at Class.run (/private/tmp/cool-app/node_modules/@angular/cli/commands/test.js:29:25) at Class.<anonymous> (/private/tmp/cool-app/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17) at process._tickCallback (internal/process/next_tick.js:103:7) diagnostics: [ ‘…/…/…/workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/plugin.ts (48,25): Cannot find name 'Promise'. (2304)’, ‘…/…/…/workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/plugin.ts (148,43): Property 'assign' does not exist on type 'ObjectConstructor'. (2339)’, ‘…/…/…/workspace/js/ng/angular-cli.git/packages/@ngtools/webpack/src/plugin.ts (349,25): Cannot find name 'Promise'. (2304)’ ] }

Mention any other details that might be useful.

Project is located at /tmp/cool-app Angular CLI is from master, npm link’d

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
filipesilvacommented, Feb 10, 2017

This is an unfortunate side effect of Karma auto-loading ts-node. It should only happen on dev setups that have a linked CLI.

Current workaround is to do rm -rf node_modules/ts-node on the generated project. This will break ng e2e until ts-node is reinstalled locally.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: TSError: Unable to compile TypeScript - Stack Overflow
My Project is built on Angular4 with typescript, e2e testing with protractor & karma. Travis-ci has this error: [03:34:54] E/launcher - Error: ...
Read more >
Unit Tests in Angular Apps — Lessons Learned - Medium
It's not that your tests are failing. They are not even compiling anymore. You cannot even find which tests are passing/failing until you...
Read more >
TypeScript configuration - Angular
Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration.
Read more >
I got Unable to compile TypeScript error - CircleCI Discuss
[test:execute] TSError: ⨯ Unable to compile TypeScript: [test:execute] src/step_definitions/DEMO_RESTAPI.steps.ts(5,24): error TS2307: Cannot ...
Read more >
error: failed to initialize angular compilation - ngcc failed.
As misha130 suggested in the comments, there was (a single) library not aligned with the latest Ivy changes which was causing the error....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found