NodeJS: Difference between revisions

From Wiki RB4
Line 20: Line 20:
  C:\Users\U1728\AppData\Roaming\npm-cache
  C:\Users\U1728\AppData\Roaming\npm-cache


  npm install %Modulname // see C:\Uwes\Programme\nodejs\node_modules\..
  npm install %Modulname // -g installs to standard directory C:\Users\U1728\AppData\Roaming\npm\node_modules
                        // if -g is missing it will install it to current directory .\node_modules


===Examples===
===Examples===

Revision as of 14:59, 22 January 2021

Concept

Node.js ist eine plattformübergreifende Open-Source-JavaScript-Laufzeitumgebung, die JavaScript-Code außerhalb eines Webbrowsers ausführen kann.

node -v // prints version

Node.js has a set of built-in modules which you can use without any further installation, Consider modules to be the same as JavaScript libraries (see require or export).

npm

npm (ehemals Node Package Manager) ist ein Paketmanager für die JavaScript-Laufzeitumgebung Node.js. Unter dem Namen npm Registry bzw. npm Open Source wird ein Repository betrieben, über das 350.000 Pakete (Stand 13. Januar 2017[4]) unter einer freien Lizenz bereitgestellt werden. npm is the world's largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well.

npm consists of three distinct components:

  • the website
  • the Command Line Interface (CLI)
  • the registry

Use the website to discover packages, set up profiles, and manage other aspects of your npm experience. For example, you can set up organizations to manage access to public or private packages. The CLI runs from a terminal, and is how most developers interact with npm. The registry is a large public database of JavaScript software and the meta-information surrounding it.

npm -v // prints version
C:\Users\U1728\AppData\Roaming\npm
C:\Users\U1728\AppData\Roaming\npm-cache
npm install %Modulname // -g installs to standard directory C:\Users\U1728\AppData\Roaming\npm\node_modules
                       // if -g is missing it will install it to current directory .\node_modules

Examples

  • see C:\Uwes\javascripts\test

Test1

  • test1.js
var http = require('http'); // use module http
http.createServer(...).listen(8282)
node test1.js // creates a http server which listens to port 8282
http://localhost:8282 // netstat -a

Installation

The NPM program is installed on your computer when you install Node.js