Zookeeper
Node. js official: http:/nodejs.org
Select the appropriate installer or installation package based on your PC and operating system.
After the installation is complete, the corresponding executable commands will appear, but these commands do not belong to windows, so you need to configure the directory to the path environment attribute. Use ";" to separate different paths.
Express is the most commonly used framework (Development Kit) in Node. js. It can be used to quickly build a WEB project.
There are two download Methods: Download the SDK for only one project, or for the entire Node. js development environment.
Npm install-g express and '-G' indicate global, for the entire Node. js. Otherwise, it is only for a project.
Initialize the project:
As long as it is a development project, you must have a file directory to save the project. In this case, the directory is defined as nodespace.
Mkdir nodespace
Then go to this directory (imagine the Eclipse workspace where multiple projects can be defined in one workspace.
Cd nodespace
The following is a very important step. You need to create an express Project (with clear folder requirements ).
Express-e nodedemo
Note: When performing the preceding steps, I always report the following error: 'express 'is not an internal command or an external command (my computer is win7 64-bit)
Later I thought it was a version issue and I tried it.
Npm install-g express will install the latest version, which is 4.0.0 currently. If it is changed to 3.5.0, it can be executed normally as above. The command is
Npm install-g express@3.5.0
Project Structure
If you want to start the server, directly go to the myproject directory and enter: node app. js;
Express seems to be a problem,
There are two solutions:
First, download "npm install express" again in this project ". The node_modules directory also exists in the myproject directory, and the express package is saved.
Second: Create an environment variable: NODE_PATH: C: \ Users \ zhang \ AppData \ Roaming \ npm \ node_modules (the directory of express)
After the program runs, the following message is displayed:
Express server listening on port 3000 |
Indicates listening on port 3000. Then open the browser and enter: http: // localhost: 3000
If the following problems occur:
Continue to install ejs: npm install-g ejs. After successful, refresh the page:
This is the default display interface. The content of this interface is saved in the views directory.
But now there is a small problem, if you want to run Node. now, only the "node app. js ", and such a running method, if the app. after the js file is modified, it is often necessary to restart to load new content, which is very inconvenient for development,Therefore, you can use a supervisor package to dynamically load the modified development program.
Download: supervisor
Npm install-g supervisor
Then directly use the supervisor
Method to run the program:
Supervisor app. js
In the future, every file change in the project can be monitored in a timely manner, and new code files can be loaded in a timely manner, which is very convenient for development, but a little inconvenient:
If the code is incorrect during each modification, the background will always report an error.
Zookeeper