The environmental construction tutorial of Node.js, front-end automation development

Why is our front-end automation

I believe any language development, no matter what language, the teacher speaks like this, as a developer, your biggest The energy should be placed on the top of the creativity, don’t you repeat myself don’t repeat themselves, and during our development process, there are often a lot of duplicate operations, so we need to go to these operations, more Time to let us create.

Which automation can be brought about by automation:

1. Automatic compilation (LESS, SASS, etc. Automatic compilation)


2. Automatic merge (multiple JS files introduced in page, or CSS file, combined into the same and compressed)


3. Automatic refresh (IDE save, browser Refresh, automatically see the effect)


[12. Automatic deployment (automatically package the project package to the specified directory)


5. Automatic synchronization (easy to implement multiple browsing Window, synchronous click, input, debugging)

Does it feel very angry, can help us do so many things, so let’s take it, this time, including environmental construction, tool construction, The project architecture is built, served, today, the initial construction of the environment, the NodeJs environment is built.

Second, what is node.js?

Node.js® IS A JavaScript Runtime Built On Chrome’s V8 JavaScript Engine. Node.js Uses An Event-Driven, Non-Blocking I / O Model That Makes It Lightweight and EffIcient. Node.js’ Package EcoSystem, NPM, is The Largest EcoSystem of Open Source Libraries in The World.

Translation One is: node.js is a chrome based on Chrome The YavaScript of the V8 engine, which uses event drivers, non-blocking I / O models, very light and efficient, package management tool NPM, is the world’s largest open source ecosystem.
  Meet, the original browser will do a lot of things, page rendering, JS rendering, etc., then Node takes the JS rendered engine, and You used Google's V8, and then encapsulated a layer of API outside it, allowing it to have a document reading and writing, network, etc., providing a server running environment, but it is running JavaScipt. So nodejs brought a industrial revolution to the front-end development industry.  
Third, install node.js

There are a variety of ways, https: //nodejs.org/EN/ can be directly in the official website, download Installation version installation, this way is very simple, the next step is solved, there is not much introduction, introduce another way, NVM installation, because sometimes we can use multiple versions of Node, and NVM You can make us use the version of the use of the use of easy to switch.

The first step below NVM package, https: //github.com/reybutler/nvm-windows/releases, we choose the first: nvm-noinstall.zip download is completed to decompress to a place, such as : C: \ dev \ NVM file list is like this: elevate.cmd, elevate.vbs, install.cmd, license, nvm.exe

and then double-click install.cmd will let you enter “an absolute path to compress or decompress files copied to” first do not ignore it, directly enter, after a successful, will generate a text settings.txt at the root of the C drive file, this file to cut C: \ dev \ nvm directory, its contents and then we modified this:

root: C: \ dev \ nvm path: C: \ dev \ nodejs arch: 64 proxy: none



then we started the configuration environment variable, because just click on the file install.cmd, so will the system variables environment variables, generates two environment variables: NVM_HOME and NVM_SYMLINK we start modifying variable values ​​of these two variables name: NVM_HOME of the variable value: C: \ dev \ nvm; NVM_SYMLINK the variable value: C: \ dev \ nodejs

then we configure the PATH environment variable to add
% NVM_SYMLINK%,% NVM_HOME% ,  
open cmd , enter the command
nvm -v

to see the version information on the installation was successful

then download nodejs, enter the command, nvm install lastest can be downloaded Node latest version, if you want to specify the version, may be
nvm install 6.4.0

, if the computer is 32-bit, followed by the note 32,

nvm install 6.4.0 32 because the default is 64-bit

four, npm install

each node version of our installed already comes with a npm, but because we may have to switch nodWhen the E version, then in order to unify, we need to install a global npm First we enter the command mode, enter npm config set prefix “C: \ DEV \ NVM \ npm”

Enter, this is to configure the global installation path of NPM, then generate a .npmrc file under the user folder, you can see the following with the notepad to open:

prefix = C: \ DEV \ NVM \ npm

Then continue in the command:

npm install npm -g

will find the NPM package is being downloaded after entering bus, in C: \ DEV \ NVM \ In the npm directory, you can see the files in the download, and we will install the package in the global path we just configured when using the -g when we use the NPM installation package.

We configure environment variables for this NPM: Variable name: npm_home, the variable value is: C: \ DEV \ NVM \ npm
The top of PATH

% npm_home%

, pay attention, this must be added before % NVM_SYMLINK% , so we put it directly to the top of Path

Finally, we will open a command window, enter npm -v, at this time, we use the NPM package we unified to download.

We can also install CNPM tools, which is the Chinese version of the NPM mirror library, address here: https://cnpmjs.org/, is also a copy of NPM official, because we and There is a wall in the outside world, so use this domestic relatively fast, Taobao also got a mirror library like NPM, http: //npm.taobao.org/, it and the official NPM synchronized every 10 minutes. Installation method: NPM INSTALL -G cnpm --registry = http://r.cnpmjs.org
or with Taobao

npm install -g cnpm –registry = https: //registry.npm.taoba.org


After installing CNPM, directly execute
cnpm install

package name,
CNPM Install Bower -G Yes. -g is just to install the package under the global path. If you don’t install it, you can also install it in the current directory, no -g can be.
  5, NRM installation  

What is NRM? NRM is NPM Registry Manager is also NPM's mirror source management tool, sometimes foreign resources are too slow, then we can use this to switch mirror sources. We only need to pass this command:
npm install -g nrm

can be installed.

Note: -g can be placed directly to INSTALL, we will use this later, because so, we can switch the recent command in the CMD arrow It is easy to modify, more convenient to operate. After the installation is complete, we can use it. Command: NRM LS

is used to display all swangled mirror addresses

command:
Nrm USE CNPM

We can directly Switch to CNPM. Of course, it can also be switched in accordance with other contents of the above.

Summary

The above is the full content of this article, I hope this paper is to learn or work in everyone.If you have any questions, you can leave a message, thank you for your support of Tumi Cloud.


© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment