After using apt to install tsc, I find myself in a dilemma on how to either delete or upgrade it

After realizing I was missing Typescript on my server, I attempted to run the 'tsc' command. However, I received a message suggesting I use 'apt install tsc' instead. Without much thought, I executed the command. Normally, I would install Typescript using 'npm i -g typescript', but this time it installed an outdated version (2.7.x) instead of the required 4.0+. Running 'tsc -v' confirms the version mismatch, yet updating with 'apt-get update' or checking 'dpkg --list' show no signs of the incorrect installation. Attempts to remove it with 'apt-get remove' or 'apt remove' fail, as the package cannot be found. The 'tsc' command still works but throws errors due to the old version. Even trying 'npm uninstall -g typescript' proves ineffective.

How can I properly remove this erroneous Typescript installation and reinstall it through npm?

Additionally, it's worth mentioning that the issue persists regardless of the directory on the server.

For reference, here is a screenshot showcasing some of the commands I have tried and their outcomes: https://i.stack.imgur.com/12eox.png

Answer №1

(Please refer to the ongoing chat discussion for more details)

In summary: The issue likely arises from having previously installed the node-typescript package using apt-get, which only includes v2.7.2 as the latest TypeScript version for Ubuntu 18.04 LTS (also known as Bionic Beaver).

To resolve this, you have two options:

  • Upgrade to a newer Ubuntu version (such as the latest stable release, 20.04 - Focal Fossa), offering v3.8.3 as the current TypeScript version, or
  • Remove the node-typescript package using
    sudo apt-get remove node-typescript
    and install TypeScript through NPM instead. This ensures that TypeScript updates are independent of Ubuntu releases.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to access the 'create' property from an undefined source

Currently, I am immersed in a tutorial that delves into the creation of an app using Express, Nodejs, Sequelize, and Postgres. Everything seemed to be going smoothly until I encountered a roadblock - my GET route is functioning perfectly fine, but the POST ...

Deleting items from a nested array within MongoDB using Node.js

I am encountering an issue where the code provided does not seem to work for me, despite trying various similar alternatives. Here are the details of my problem: [{ "_id": { "$oid": "628cadf43a2fd997be8ce242" }, &quo ...

Utilizing Angular to convert a string array into an array of enum values through an HTTP GET request

I have a list of different user roles defined in my typescript code: enum UserRole { CONSULTANT, MANAGER, ... } There is a REST endpoint /users/id/roles that returns an array of strings representing the roles of a specific user: [ "CONSU ...

Implementing a data retrieval process in MongoDB for displaying on a localhost server using Node.js

Currently, I'm in the process of developing a to-do list application using mongoDB and node.js. The concept is simple - you enter your tasks and then click 'add'. I've managed to establish a connection with the database successfully. Ho ...

How to pass a String Array to a String literal in JavaScript

I need to pass an array of string values to a string literal in the following way Code : var arr = ['1','2556','3','4','5']; ... ... var output = ` <scr`+`ipt> window.stringArray = [`+ arr +`] & ...

The pivotal Angular universal service

In my application, I have the need to store global variables that are specific to each user. To achieve this, I created a Service that allows access to these variables from any component. However, I am wondering if there is a way to share this service t ...

Executing code after sending a response in NodeJS with Graphql: Is it possible?

I have a unique endpoint that receives special files and automatically initiates a background task for uploading those files to our secure cloud storage system. In order to efficiently handle the file uploads in the background, we are utilizing advanced t ...

Is sending a stream to a variable the best option, or could there be another solution

Is there a way to pipe stream data to a variable? The writable stream examples mentioned in this documentation include: HTTP requests on the client side HTTP responses on the server side Zlib streams Crypto streams TCP sockets Child process stdin Process ...

Ways to refresh the cache after performing delete, update, or add operations on data

I currently utilize a data caching tool called cache-all. However, I have encountered an issue where newly added information does not appear when displaying all data after the addition. To ensure that new data is immediately reflected in requests, I typica ...

What is the importance of using sequelize 'seed'?

Can someone explain the seed concept in the sequelize npm package to me? I have not been able to find information on this in any tutorials, and I am curious about why we need SEED. Thank you! ...

Retrieve information from a changing HTML table

I am working on a nodejs express project that features a Dynamic Table within my application. Users can add or remove rows and enter values into cells, but I am struggling to extract these values from the table without using jquery. My goal is to then inse ...

Using TypeScript, creating a tagged template literal for running Jest tests with the `test.each`

Struggling to construct a jest test.each with a tagged template literal test.each` height | text ${10} | ${undefined} ${20} | ${undefined} ${10} | ${'text'} ${20} | ${'text'} `('$height and $text behave as expected&a ...

acquire the JWToken using Cypress and establish it as the header for subsequent requests

While attempting to test an Express web application I developed, the first step is authentication to retrieve a JWT token. The token retrieval process works fine, but when trying to set the header for subsequent requests, it doesn't seem to work. Thi ...

The paths specified in Node.js and Express are having difficulty finding the resource files for CSS and JavaScript

I am currently using Express to develop a basic website. Everything was running smoothly until I attempted to add the following code to handle 404 errors: app.get('/*', function(req, res) { res.render('404.ejs',{ title: ' ...

res.json cannot be called

I have a file that contains the following function which returns JSON data. I am trying to call this function from another file. exports.me = function(req, res) { var userId = req.user._id; User.findOne({ _id: userId }, function(err, user) { ...

Is there a way for me to convert my (TypeScript Definition) .d.ts file into a (JavaScript) .js file?

It seems that there are plenty of guides available on converting a file from .js to .d.ts, but not the other way around. Specifically, I have some code in .d.ts format and I would like to convert it into JavaScript. Can anyone offer assistance with this t ...

Varnish is preventing HTML redirects from being executed properly

I've encountered an issue with my setup involving Varnish 3.0 on Ubuntu 11 and ExpressJS v2.5.8 (running on Node.js 0.6). When I try to do a redirect using Express, it works fine without Varnish in between. However, when Varnish is added into the mix, ...

Saving this object in Mongodb - here's how it's done

click here for imageCan you provide guidance on creating a schema and saving API data for this specific object in MongoDB? I am looking to store the information related to 'btcinr' as it will be fetched from an external API. Below is the sample ...

Errors encountered while running `npm install discord.js`

I am currently facing an issue while trying to install discord.js. Unfortunately, I keep encountering the following errors: npm ERR! cb() never called! npm ERR! This is an error with npm itself. Please report this error at: npm ERR! <https://npm.co ...

How can I retrieve a text file using an API in a Next.js application?

Is there a way to download a text file using an API in Next.js? The console.log(ninjas) function is already displaying the correct information. I have tested the API with Postman and it works perfectly. When I use GET in Postman, the same information is ...