npm i
Downloads all the needed node modules and configures this project without the need of following the instructions below
- Make sure to download Node.JS & NPM first
npm init -y
Initializes a package.json filenpm i -g typescript
Downloads & Installs the latest version of TypeScripttsc --init
Creates a TypeScript configuration file called tsconfig.json- Inside the tsconfig.json file:
- Change the
target
property toes6
- line 5 - Uncomment both outDir & rootDir - lines 15 and 16
- Use
./dist
foroutDir
&./src
forrootDir
- Uncomment
moduleResolution
property - line 42
- Change the
- Create a src folder
- Inside package.json file; below the
"scripts"
object - line 6:- Add
"start": "node dist/server.js"
for your server - Add
"start:dev": "tsc -p . --watch"
watches and compiles all your TypeScript files into JavaScript after you save automatically
- Add
Make sure to have an existing TypeScript file to execute the following command:
- To compile TypeScript into JavaScript; use
npm run start:dev
- Run
npm i -g npm
to install/update npm to the latest version - Run
npm i @types/node
to install node types
npm i -D jest typescript --force
Downloads Jestnpm i -D ts-jest @types/jest
Downloads Jest typesnpx ts-jest config:init
Creates a jest.config.js file Make sure to remove testEnvironment: 'node' You can read further about configuring jest.config.js here- Add
"test": "jest"
inside package.json - Use
npm run test
to initialize both JavaScript and TypeScript tests simultaneously
Updated on the 13th of June, 2020 @ 10:01 P.M