MAC Configuration Node.js development environment, express installation, create project
First, the installation of Node.js
Go to the official website to download the corresponding platform version is OK, https://nodejs.org
Second, express installation
sudo npm install-g Express for global installation.
It is possible that the installation will not succeed, with the following command
sudo npm install express-generator-g
Third, create the project
Terminal input EXPRESS-E your project name
-E for using the EJS Framework Express defaults to Jade, in order to learn difficult we recommend the use of Ejs
Node.js Development Guide Book Here is a mistake: express-t Ejs microblog, the correct should be express-e Ejs microblog;
Then according to the above prompts operation, input http://localhost:3000 can see the content.
Here is my record of operations:
Appledeimac:demo apple$ express-e ejs microblog2 create:microblog2 Create: Microblog2/app.js create:microblog2/public create:microblog2/routes create:microblog2/routes/index.js cr Eate:microblog2/routes/users.js create:microblog2/public/images create:microblog2/views create:microblog2 /views/index.ejs Create:microblog2/views/error.ejs create:microblog2/public/stylesheets create:microblog2/p Ublic/stylesheets/style.css create:microblog2/bin create:microblog2/bin/www Install dependencies: $ cd MICROBLOG2 && NPM Install run the app: $ debug=microblog2:* npm start Create:microblog2/public/java Scripts Appledeimac:demo apple$ cd microblog2 appledeimac:microblog2 apple$ npm Install microblog2@0.0.0/users/apple/ Desktop/node/demo/microblog2├─┬body-parser@1.13.3│├──bytes@2.1.0│├──content-type@1.0.1│├──depd@1.0.1│├─┬ Http-errors@1.3.1││├──inherits@2.0.1││└──statuses@1.2.1│├──iconv-lite@0.4.11│├─┬on-finished@2.3.0││└──ee-first@1.1.1│├──qs@ 4.0.0│├─┬raw-body@2.1.5││├──bytes@2.2.0││├──iconv-lite@0.4.13││└──unpipe@1.0.0│└─┬type-is@1.6.10│
├──media-typer@0.3.0│└─┬mime-types@2.1.9│└──mime-db@1.21.0├─┬cookie-parser@1.3.5│├──cookie@0.1.3 │└──cookie-signature@1.0.6├─┬debug@2.2.0│└──ms@0.7.1├──ejs@2.3.4├─┬express@4.13.4│├─┬accepts@1.2.13│
│└──negotiator@0.5.3│├──array-flatten@1.1.1│├──content-disposition@0.5.1│├──cookie@0.1.5│├──depd@1.1.0 │├──escape-html@1.0.3│├──etag@1.7.0│├──finalhandler@0.4.1│├──fresh@0.3.0│├──merge-descriptors@1.0.1│ ├──methods@1.1.2│├──parseurl@1.3.1│├──path-to-regexp@0.1.7│├─┬proxy-addr@1.0.10││├──forwarded@0.1.0││ └──ipaddr.js@1.0.5│├──range-parser@1.0.3│├─┬send@0.13.1││├──depd@1.1.0││├──destroy@1.0.4││└──mime @1.3.4│├──serve-static@1.10.2│├──utils-merge@1.0.0│└──vary@1.0.1├─┬morgan@1.6.1│├──basic-auth@1.0.3│└──on-headers@1.0.1└─ ─serve-favicon@2.3.0 appledeimac:microblog2 apple$ debug=microblog2:* npm Start > microblog2@0.0.0 start/users/app Le/desktop/node/demo/microblog2 > Node./bin/www microblog2:server listening on port 3000 +0ms get/200 13.925 MS- 207 get/stylesheets/style.css 4.193 ms-111 get/200 2.145 ms-209 get/stylesheets/style.css 304 0.507 MS-GE t/304 1.015 MS--GET/STYLESHEETS/STYLE.CSS 304 0.255 MS--get/304 0.587 MS--GET/STYLESHEETS/STYLE.CSS 304 0.2
MS--