0

I am trying to upgrade TypeScript from 3.4.5 to 4.5.4 having migrated a NativeScript project from version 6.5.0 to 8.1.5.

Ideally to completely remove the old TypeScript 3.4.5 but it still seems to be there. I have checked the other similar queries like this one but have not been able to get rid of it. I do not have Visual Studio installed.

Am using nvm and am currently on node 16.10.0 and npm 7.24.0

My package.json has "typescript": "^4.5.4", in the dependencies. Here is the whole package.json.

{
  "description": "Reports App | Mobile Expense Reports",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "lint": "tslint \"app/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "~13.1.1",
    "@angular/common": "~13.1.1",
    "@angular/compiler": "~13.1.1",
    "@angular/core": "~13.1.1",
    "@angular/forms": "~13.1.1",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "~13.1.1",
    "@angular/platform-browser-dynamic": "~13.1.1",
    "@angular/router": "~13.1.1",
    "@master.technology/permissions": "~2.0.1",
    "@nativescript-community/ui-material-bottom-navigation": "^6.2.11",
    "@nativescript/angular": "~13.0.0",
    "@nativescript/core": "~8.1.1",
    "@nativescript/fingerprint-auth": "8.0.0",
    "nativescript-app-sync": "^2.0.0",
    "nativescript-bottom-navigation": "^2.0.5",
    "nativescript-camera": "^4.5.0",
    "nativescript-drop-down": "^6.0.1",
    "nativescript-fancyalert": "~3.1.1",
    "nativescript-fingerprint-auth": "~7.0.2",
    "nativescript-fontawesome": "^1.0.0",
    "nativescript-gradient": "^2.0.1",
    "nativescript-imagepicker": "~7.1.0",
    "nativescript-iqkeyboardmanager": "^1.5.1",
    "nativescript-modal-datetimepicker": "~2.1.5",
    "nativescript-pdf-view": "^3.0.0-1",
    "nativescript-permissions": "~1.3.12",
    "nativescript-theme-core": "~2.0.24",
    "nativescript-toast": "^2.0.0",
    "nativescript-ui-listview": "~10.0.2",
    "reflect-metadata": "~0.1.10",
    "ruby": "^0.6.1",
    "rxjs": "~7.4.0",
    "typescript": "^4.5.4",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.1.1",
    "@angular/compiler-cli": "~13.1.1",
    "@nativescript/android": "~8.1.1",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "~13.1.1",
    "@types/node": "14.6.2",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "codelyzer": "~4.5.0",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "sass": "~1.39.0",
    "tslint": "~5.12.1",
    "uglifyjs-webpack-plugin": "^2.2.0"
  },
  "main": "main.js"
}

I have tried many things like

npm uninstall -g typescript
npm install -g typescript
ns clean
npm install

And I still get

$ tsc -v
Version 3.4.5

I cannot see where it is pulling it from.

ng --version gives:

Angular CLI: 13.2.2
Node: 16.10.0
Package Manager: npm 7.24.0
OS: win32 x64

Angular: 13.1.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1301.4
@angular-devkit/build-angular   13.1.4
@angular-devkit/core            13.1.4
@angular-devkit/schematics      13.2.2 (cli-only)
@angular/http                   8.0.0-beta.10+1.sha-a28b3e3
@ngtools/webpack                13.1.4
@schematics/angular             13.2.2 (cli-only)
rxjs                            7.4.0
typescript                      4.5.4

I also tried deleting node_modules, hooks and platforms and reinstalling but tsc still gives v3.4.5.

Can you see what version I am on?

======== UPDATE

I did it (in Windows) by deleting the

C:\Users\User\AppData\Roaming\npm\node_modules\typescript

folder and replacing it with the

C:\Program Files\nodejs\node_modules\typescript

folder.

I think when running

npm i -g typescript NVM was saving it to

C:\Program Files\nodejs\node_modules

and

C:\Users\User\AppData\Roaming\nvm\v16.10.0\node_modules

but not

C:\Users\User\AppData\Roaming\npm\node_modules

4
  • Is there a particular reason to install it globally? Most systems (including TypeScript) don't recommend doing that nowadays. Part of the problem is that tsc is different from npx tsc in your case. See Download TypeScript Commented Feb 11, 2022 at 15:23
  • Hi @crashmstr when I do npm i typescript --save-dev it goes into the project node_modules but tsc -v doesn't see it. I get node:internal/modules/cjs/loader:936 throw err; ^ Error: Cannot find module 'C:\Users\User\AppData\Roaming\npm\node_modules\typescript\bin\tsc' ... /run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND'', requireStack: [] } Commented Feb 11, 2022 at 15:39
  • You use npx tsc -v to reference the project installed version. This also allows different project to work with different versions. This is how almost all npm packages are set up for now instead of installing globally. Commented Feb 11, 2022 at 15:46
  • If you look at typescriptlang.org/download, npx tsc is what is shown on the TypeScript site. Commented Feb 11, 2022 at 15:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.