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 -yInitializes a package.json filenpm i -g typescriptDownloads & Installs the latest version of TypeScripttsc --initCreates a TypeScript configuration file called tsconfig.json- Inside the tsconfig.json file:
- Change the
targetproperty toes6- line 5 - Uncomment both outDir & rootDir - lines 15 and 16
- Use
./distforoutDir&./srcforrootDir - Uncomment
moduleResolutionproperty - 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 npmto install/update npm to the latest version - Run
npm i @types/nodeto install node types
npm i -D jest typescript --forceDownloads Jestnpm i -D ts-jest @types/jestDownloads Jest typesnpx ts-jest config:initCreates 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 testto initialize both JavaScript and TypeScript tests simultaneously
Updated on the 13th of June, 2020 @ 10:01 P.M