Knowledge of front-end entry summary --Node.js

Now the front-end business increasingly large, front-end code also requires a variety of tools to go with the completion of modular and engineering. Node.js is a JavaScript runtime environment Chrome V8 engine. Node.js uses an event-driven, non-blocking I / O model, making it lightweight and efficient. Node.js package manager npm, the world's largest repository of open source ecosystem.

End native code development, need to be deployed to the server, you need a lot of JavaScript code will be packaged into a line of code in order to reduce the number of requests resources.

Previously learned JavaScript and can not relate to file operations, because its operating environment is the browser, can only be called BOM, DOM.

Node.js is a JavaScript runtime environment, so that we can run the code on the local server or JavaScript. This is because Node.js gives us a lot of interfaces:

  • File System (file operation)
  • HTTP (Web Services)
  • OS (operating system calls)
  • C ++ Addons (call C ++ modules)

Once you have Node.js, JavaScript can do more things, such as Web servers, native application (such as VS code), build tools.


Node.js installation

Access Node.js official website

LTS version represents LongTimeSupport, namely long-term support version, stable version, the online version of the general use.

After installation, you can be entered at the command line node -vto detect whether the installation is successful.

At the command line node, you can enter the JavaScript runtime environment. Enter .exitor press twice ctrl+Cto exit.


asl

While installing Node.js, and also installed npm.

Node.js package manager npm, the world's largest repository of open source ecosystem. Similar to Taobao, npm is a platform, you can upload your own code, you can also download other people's open-source code.

Since it is a platform, the platform will have a standardized platform. npm specification is package.json this profile. npm for packet management and identification based on this profile.

  • Upload:npm publish
  • download:npm install

Command-line tool

npm install ugligy-js -g

Represents the above command, the global installation uglify.jsof this kit compressed code, -gthe setup is global.

By using the command line uglify.js:

uglifyjs ./index.js -o index.min.js

Different tools usage is different, you can see specific documentation.

Note: The node app.jscommand can be run JavaScript files in Node environment app.js.

Original: Large column  front-end summary of knowledge entry --Node.js


Guess you like

Origin www.cnblogs.com/wangziqiang123/p/11618276.html