Categories
TypeScript Answers

How to install and run TypeScript locally in npm?

Spread the love

Sometimes, we want to install and run TypeScript locally in npm.

In this article, we’ll look at how to install and run TypeScript locally in npm.

How to install and run TypeScript locally in npm?

To install and run TypeScript locally in npm, we can install the typescript package as a dev dependency.

To install it, we run

npm i typescript --save-dev

Then we can add the tsc script into package.json with

{
  "name": "foo",
  "scripts": {
    "tsc": "tsc"
  },
  //...
}

And then we can run npm run tsc to run tsc in our project.

Conclusion

To install and run TypeScript locally in npm, we can install the typescript package as a dev dependency.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *