diff --git a/lib/bootstrap-local.js b/lib/bootstrap-local.js index a4e2d58e3438..a4043c34437f 100644 --- a/lib/bootstrap-local.js +++ b/lib/bootstrap-local.js @@ -12,7 +12,7 @@ global.angularCliPackages = require('./packages'); const compilerOptions = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json'))); const oldRequireTs = require.extensions['.ts']; -require.extensions['.ts'] = function(m, filename) { +require.extensions['.ts'] = function (m, filename) { // If we're in node module, either call the old hook or simply compile the // file without transpilation. We do not touch node_modules/**. // We do touch `Angular CLI` files anywhere though. @@ -52,6 +52,9 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) { const Module = require('module'); const oldLoad = Module._load; Module._load = function (request, parent) { + if (request.match(/ts-node/) && parent && parent.id && parent.id.match(/karma/)) { + throw new Error(); + } if (request in packages) { return oldLoad.call(this, packages[request].main, parent); } else if (request.startsWith('@angular/cli/')) {