0

I use npm as my build tool and one of the entries in the scripts dictionary of my packages.json file is "tsc", which causes the .ts files in my project to be compiled. However I noticed that I was getting different TypeScript error messages when I call > tsc directly v.s. calling > npm run start. I updated the script entry to (tsc -v; tsc), and I get:

> npm run build
message TS6029: Version 1.6.2

whereas as If I call the same command directly, I get:

> (tsc -v; tsc)
Version 1.8.10

What could cause this behavior?

Jthorpe
  • 9,756
  • 2
  • 49
  • 64
  • There's a different pointer to the compiled code version of typescript than the one that the pre-compiler is looking at. – wahwahwah Jun 23 '16 at 03:32

2 Answers2

0

Oops. Looking over my package.json file, I realized that the devDependencies included this entry: "typescript": "~1.6.2". I updated it to ~1.8.10 and did a > npm install and the problem went away.

Jthorpe
  • 9,756
  • 2
  • 49
  • 64
0

Another consideration (for those who may also experience a similar issue, but without having a direct dependency), is that other npm packages could have a dependency on TypeScript, and those packages are using an older version. In this scenario, you won't see anything in your package.json file, but npm will find the transitive dependency and use that.

For example, the grunt-typescript module has a dependency on TypeScript, but the module is old and outdated--even though it still works. This could cause conflicts with having tsc -p . inside of a postinstall script.