Building a Typescript development environment on macOS

Building a Typescript development environment on macOS with NPM

There are two ways to build the TypeScript development environment, one using Visual Studio and the other using the npm package manager.

NodeJS Installation

NodeJS must be installed prior to using npm.
After installing NodeJS, run terminal and check whether nodeJS is properly installed using the node command.
lucidmaj7@Wonheeui-MacBookPro ~ % node --version

v12.16.0

lucidmaj7@Wonheeui-MacBookPro ~ %
Check if npm is running normally.
lucidmaj7@Wonheeui-MacBookPro ~ % npm



Usage: npm <command>



where <command> is one of:

access, adduser, audit, bin, bugs, c, cache, ci, cit,

clean-install, clean-install-test, completion, config,

create, ddp, dedupe, deprecate, dist-tag, docs, doctor,

edit, explore, fund, get, help, help-search, hook, i, init,

install, install-ci-test, install-test, it, link, list, ln,

login, logout, ls, org, outdated, owner, pack, ping, prefix,

profile, prune, publish, rb, rebuild, repo, restart, root,

run, run-script, s, se, search, set, shrinkwrap, star,

stars, start, stop, t, team, test, token, tst, un,

uninstall, unpublish, unstar, up, update, v, version, view,

whoami



npm <command> -h  quick help on <command>

npm -l  display full usage info

npm help <term> search for help on <term>

npm help npm  involved overview



Specify configs in the ini-formatted file:

/Users/lucidmaj7/.npmrc

or on the command line via: npm <command> --key value

Config info can be viewed via: npm help config



npm@6.13.4 /usr/local/lib/node_modules/npm

lucidmaj7@Wonheeui-MacBookPro ~ %
It seems to have worked well.

Installing Typescript using NPM

Typescript can be installed through the following command.
npm install -g typescript
But .. installation is not possible. ㅎ The
message that you do not have permission is displayed. Let's sudohit together to elevate .
sudo npm install -g typescript
You can see that it is installed normally.

Typescript example test

Let's test the Typescript example.
Create a tsfile in the appropriate place and enter the Typescript code below.
function sayHello(person: string) { 
    return  "Hello, " + person; 
}  
let user = "Jane User";  
document.body.textContent = sayHello(user);
tcsBuild the typescript code entered using the command.
% tsc test.ts
Then test.jsyou can see the file is created.
Now let's load it from the html file and run it on the web page.
<!DOCTYPE html>  
<html>  
<head><title>TypeScript sayHello</title></head>  
<body>  
    <script src="test.js"></script>  
</body>  
</html>
When I open it in the browser, it outputs as follows normally.
I built the Typescript development environment in macOS simply.

Reference

Comments

Popular posts from this blog

Enabling Com Port on Hyper-V 2nd Generation VM / Windbg

DLL Injection using CreateRemoteThread in Windows 10

Using Overlapped I / O in DeviceIoControl