npm installing old versions of (typescript compile

2019-07-15 02:24发布

问题:

On a windows environment, I have: node v4.6.0 npm v3.10.8

my local typescript version is: npm run tsc -v 3.10.8

However, I sometimes want to use my global tsc (because for some reason, gulp uses the global tsc) but when I do:

npm install tsc -g tsc -v I get a version 1.5.3 for my typescript compiler

when I try to force install it to the exact version I need: npm install tsc@3.10.8 -g I get: ` npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\DT\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "tsc@3.10.8" "-g" npm ERR! node v4.6.0 npm ERR! npm v3.10.8 npm ERR! code ETARGET

npm ERR! notarget No compatible version found: tsc@3.10.8 npm ERR! notarget Valid install targets: npm ERR! notarget 1.20150623.0, 1.20150622.0, 1.20150619.0, 1.0.0 `

Btw with my default installation of node, my npm version is 2 something but I can update it to 3.10.8, that works. For typescript however, no way.

Any ideas?

PS:my platform is windows 10

回答1:

Had the same problem and this worked for me:

  1. Go to "C:\Program Files (x86)\Microsoft SDKs" and delete the TypeScript folder.
  2. Uninstall previous version (npm uninstall -g typescript)
  3. Reinstall typescript.