I want to be able to run npx tsc
on my project on both my host + guest operating systems. But the guest is using a different (older) version of tsc
- and I'm not sure where it's coming from.
My setup:
npm -g ls typescript
on both host+guest shows "empty", and running "tsc" alone does not work, as expected).I have a project with TypeScript 3.3.3333 installed into the project with NPM.
On the Windows host OS, when I cd
to the project folder and run:
npm ls typescript
I see output: typescript@3.3.3333
(as expected)npx tsc --version
I see output: Version 3.3.3333
(as expected)Inside the Linux guest OS, when I cd
to the project folder and run:
npm ls typescript
I see output: typescript@3.3.3333
(as expected)npx tsc --version
I see output: message TS6029: Version 1.5.3
(unexpected!)So I'm unable to run npx tsc
to compile my code inside the guest, as it doesn't support some of my newer tsconfig settings.
Where could this tsc 1.5.3 version be coming from, and how do I get rid of it?
Or is there some alternative NPM command I can run on the host that will install a usable tsc
into the project that works for both Windows+Linux?
Also, none of the parent folders above my project's root have a node_modules
folder (but of course my project's root does have its node_modules sub-folder).
TypeScript binary is called tsc
for shortness. When it's not installed globally, npx
has no way to know that tsc
refers to tsc
binary for typescript
package. npx tsc
refers to deprecated tsc
package.
A way this can be fixed is to specify package name explicitly:
npx -p typescript tsc
And the actual problem here is that the project relies on global TypeScript installation. It's common to have typescript
a project was written with in project dependencies and refer to local installation in package.json NPM scripts:
...
"scripts": {
"build": "tsc"
},
"devDependencies": {
"typescript": "~3.3.0"
"
...