What happened to my typescript compiler? `tsc --version` returns nothing

On Linux Mint, I installed node and used it to install typescript. In a working installation of typescript tsc --version should return the version number. In my case, nothing returns at all.

When I run which tsc , the result is /usr/local/bin/tsc .

When I run cat /usr/local/bin/tsc , the result is:

 #!/usr/bin/env node require('../lib/tsc.js') 

When I ran find /usr/local -name 'tsc*' , the result:

 /usr/local/bin/tsc /usr/local/lib/node_modules/typescript/bin/tsc /usr/local/lib/node_modules/typescript/lib/tsc.js 

Is it correct? If so, would any ideas on what else to see be appreciated?

Note. I also tried running /usr/local/lib/node_modules/typescript/bin/tsc --version and got the same result, i.e. nothing.

+7
source share
3 answers

I found that running node --version does not return anything (but should not), however nodejs --version works (result v0.10.25 ). Reinstalling node did not fix this. I do not know why this would be as it seems to me, I followed the recommended installation procedure.

However, edit the file / usr / local / bin / tsc and change the line:

 #!/usr/bin/env node 

to

 #!/usr/bin/env nodejs 

seemed to work. Now tsc --version returns message TS6029: Version 1.6.2 , and I get the .js files generated when run make .

+5
source

In my case on Ubuntu 16.04, the problem was because I ran sudo apt-get install node-typescript , which delivered me a broken tsc. After uninstalling with apt-get remove and then installing, as recommended, using npm install -g typescript , it worked fine.

Perhaps this will help someone.

+10
source

I got the following error in Ubuntu 16.04.6:

  internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module 'typescript/tsc.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/usr/bin/tsc:2:1) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) 

Run: npm install -g typescript did not solve the problem. So, I had to install the latest version of the node, i.e. nvm install <nvm version>

Then with npm install problem was fixed.

0
source

Source: https://habr.com/ru/post/1232498/


All Articles