Node.js - Express.js

From Sinfronteras
Revision as of 13:41, 6 November 2018 by Adelo Vieira (talk | contribs) (Installation)
Jump to: navigation, search

Curso online que Remo recomendó:

https://javascript30.com/

https://courses.wesbos.com/account/access/5bc5c20a93bbc3208321f21b

TypeScript

TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language.

TypeScript is designed for development of large applications and transcompiles to JavaScript. As TypeScript is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs. TypeScript may be used to develop JavaScript applications for both client-side and server-side.

To get started with TypeScript installation, you need to first install Node.js in your system.

Node.js

Install Node.js https://nodejs.org/en/download/ https://en.wikipedia.org/wiki/Node.js

Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Historically, JavaScript was used primarily for client-side scripting, in which scripts written in JavaScript are embedded in a webpage's HTML and run client-side by a JavaScript engine in the user's web browser. Node.js lets developers use JavaScript to write Command Line tools and for server-side scripting-running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser. Consequently, Node.js represents a "JavaScript everywhere" paradigm, unifying web application development around a single programming language, rather than different languages for server side and client side scripts.

Installation

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Alternatively, for Node.js 10:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

Optional: Install build tools. To compile and install native addons from npm, you may also need to install build tools:

sudo apt-get install -y build-essential

También hay que instalar ts-node:

sudo npm install -g ts-node

TypeScript Installation

As you have already installed Node, it's time to install the TypeScript Package using the Node Package Manager (NPM).

npm install -g typescript

Git Bash in Windows

Si estamos en Windows, tenemos que instalar Git Bash in Windows; que es tan sólo un terminal Bash en Windows.

Visual Studio Code

https://code.visualstudio.com/download/

https://en.wikipedia.org/wiki/Visual_Studio_Code

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.

Installation

Download the <file>.deb: https://code.visualstudio.com/download Installation: https://code.visualstudio.com/docs/setup/linux

Setting up a Node.js + TypeScript development environment

Compilation

Para preparar el directorio, primero hay que ejecutar:

tsc --init
npm init
npm init --y  (podemos ejecutarlo así para responder (yes) automáticamente a las preguntas.

Luego:

npm install @types/node


npm install jquery
tsc -p tsconfig.json
node demo.js
ts-node demo.ts