Locally run Stackblitz project with Typescript and RxJs

danmt

Daniel Marin

Posted on November 19, 2020

Locally run Stackblitz project with Typescript and RxJs

Yoyoyo, what's up guys?

OMG, it's been a while since my last article. A lot going on, thankfully good stuff (:

I use Stackblitz a lot. Like A LOT. Today I created a new Typescript/RxJs project, once done, I was trying to export it and run it locally. Long story short, it wasn't running locally out-of-the-box.

Lucky us, my friend Tomek Sułkowski got us covered, all it took was to reach out and ask him:

Hey Tomek, how do you locally run a Stackblitz project with Typescript and RxJs?

NOTE: If you don't follow Tomek on Twitter already, you should.

All you gotta do is:

  • Export the project from Stackblitz.
  • Extract the project into the folder of your preference.
  • Go to the project's directory using a terminal.
  • Run npm i -D parcel.

With parcel it's easy to spin up a server that properly serves the index.html file. Before continuing, add your .ts files as scripts in the index.html file.

<!-- Your HTML code -->

<script src="index.ts"></script>
Enter fullscreen mode Exit fullscreen mode

NOTE: If you have more than one .ts file, you may need to inject them all.

The last thing we're going to do is adding a new script to the package.json to serve the application.

{
  "name": "<your_project_name>",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    ...
    "serve": "parcel index.html"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    ...
  }
}
Enter fullscreen mode Exit fullscreen mode

You made it! Now call npm run serve and go to http://localhost:1234 in your browser.

NOTE: This guide is for simple projects, if you find issues trying to follow it, drop me a comment down below.

💖 💪 🙅 🚩
danmt
Daniel Marin

Posted on November 19, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related