Today do a book on the example, the result code does not work, query, is the syntax is outdated, the book is actually new bought, published soon.
The outdated code is as follows
var connect=require (' Connect '); Connect.createserver ( connect.static (". /angularjs ")). Listen (5000);
Error hint: Connect.static is not a method
Since my goal is to practice angularjs, not to learn nodejs, so do not go into the drill, as long as you can build a simple server on the line
The search method on the Internet is to create a node. js static server with Http-server
1. Global Installation Http-server
NPM install-g Http-server
2.http-server start
Http-server-a 127.0.0.1-p 5000
"
One of the commands above starts a node. js static server. Listen for local 7070 ports.
The static directory is the directory where the command is currently running
If the public folder exists in your current project, the default static directory is assigned to public
If there is no public folder, then the static directory is the root directory.
"
This passage is a reference to a http://yijiebuyi.com/blog/b0f6ddc56be457e13879a3ad105f561b.html on a commoner's blog.
The environment referred to should be Linux
You can write http-server-a 127.0.0.1-p 7070 to the Scripts node in the Package.json file
"Scripts": {
"Start": "Http-server-a 127.0.0.1-p 7070"
}
This allows you to start a static server with NPM start
Create a node. js static server with Http-server