Code Monkey home page Code Monkey logo

ts-node-template's Introduction

ts-node-template

This is boilerplate code for creating Typescript projects in a Node environment. After following the instructions you will have the basic functionality to run a Typescript project with ts-node included to your project folder.

Description

This template repo contains basic debug launch configuration for VS Code using index.ts as entry point. If you don't use VS Code as IDE, remove the folder .vscode. The file tsconfig.json includes basic configuration for the Typescript compiler used by ts-node.

Installation

  1. Clone this repo
  2. Initialize npm: npm init -y
  3. Globally install typescript and ts-node: npm i -g typescript ts-node
  4. Install typescript and ts-node as local dev-dependencies: npm i -D typescript ts-node
  5. Launch the scipt via ts-node index.ts

Feel free to remove this README.md file after installation!

ts-node-template's People

Contributors

thomas1664 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ts-node-template's Issues

Error: Cannot use import statement outside a module

I'm trying to initialize and launch this project via following commands:

$  git clone https://github.com/Thomas1664/ts-node-template.git
$ cd ts-node-template
$ npm init -y
$ npm i -D typescript ts-node
$ node ./index.ts

But, as result, I've got an error:

(node:4132010) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/user/ts-node-template/index.ts:1
import http from 'http'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

How to fix this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.