The use of common development tools of node.js

Geek Academy Course Notes

1. Network settings of VisulBox

Settings => Network => NAT Mode

Add port forwarding, add rules

name: ssh

Protocol: TCP

host port; 22

Subsystem Ports: 22

Confirm = "Log in to the virtual machine to see if the ip starts with 10.

Login in xShell

ssh [email protected] 22

Enter the password, etc.

Second, the use of sublime Text

1. Press and hold ctrl + scroll wheel to zoom in and out of the interface

2. Click on the code map to enter the corresponding section

3. Multi-cursor simultaneous editing: Ctrl+click the line to edit at the same time

4. Change the name of a variable in the entire file: double-click to select = "press alt+F3 to replace the variable in the entire page.

5. Package management tool: control package: press ctrl+tilde, paste the copied code, press Enter, wait for the installation to complete, restart sublime text

Click on preferences to see a new package control

Sublime plugins can be installed via package control

Select install package:

1) Synchronize local files to Linux: sftp click to install

Use: Create a new code directory node_jike locally, and add the code directory to sublime (project->add folder to project)

Create a new file, add a line of code, save it, and name it hellnode.js

Right-click on the node_jike folder-->map to remote

Open the configuration file:

host: change to the ip address of the virtual machine

user:

passoword

Create a directory (xshell) in the virtual machine and enter: mkdir /home/hello

Modify sftp

Change to "/home/hello/"

keep

Go to xshell to see if this file exists

cd /home/hello

ll

Check if it exists

node hello.js executable file

5. Open the file: goto anything or ctrl+P

to search and open files

 

3. The use of webstrom

create project

 

 

Dojo run-> run bin / www

Open a browser: localhost:3000

View execution results

3. npm

1. Install npm using yum on xshell

yum install npm

2. Install cnpm using npm

npm config set strict-ssl false //Cancel Npm strict mode

npm install -g cnpm //install cnpm

cd /home/hello/

cnpm install express

cnpm install -g nodemon

cnpm install -g pm2

3. Use of nodemon

nodemon hello.js

Then execute hello.js

upload when hello.js is changed

nodemon monitors the changes of hello.js and automatically executes the second time after detection.

4. Use of node-inspector

New file http.js

Create the simplest http server

var http=require('http');
http.createSever(function (req,res) {
	res.end('Hello');
}).listen(8011);

upload file

xshell turns off the firewall

systemctl stop firewalld

nodemon --debug app.js

Then open another interface

start node-inspector

cd  /home/hello/

node-inspector

Open the given address in a browser such as

http://127.0.0.1:8080/?port=5858

Change 127.0.0.1 to the domain name: geek

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324354671&siteId=291194637