Skip to content

Commit

Permalink
Print a warning when ts-node fails to load (#289)
Browse files Browse the repository at this point in the history
* Print a warning when ts-node fails to load

* Fix linter
  • Loading branch information
alcuadrado committed Jun 6, 2019
1 parent e5eef7e commit 60371f7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/buidler-core/src/internal/core/typescript-support.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import colors from "ansi-colors";
import * as fs from "fs";
import * as path from "path";

Expand Down Expand Up @@ -49,7 +50,23 @@ export function loadTsNodeIfPresent() {
process.env.TS_NODE_FILES = "true";
}

// tslint:disable-next-line no-implicit-dependencies
require("ts-node/register");
try {
// tslint:disable-next-line no-implicit-dependencies
require("ts-node/register");
} catch (error) {
// See: https://github.com/nomiclabs/buidler/issues/274
if (error.message.includes("Cannot find module 'typescript'")) {
console.warn(
colors.yellow(
"Failed to load TypeScript support. Please update ts-node."
)
);

return;
}

// tslint:disable-next-line only-buidler-error
throw error;
}
}
}

0 comments on commit 60371f7

Please sign in to comment.