Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure nodejs tutorial

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to configure nodejs tutorial". In daily operation, I believe many people have doubts about how to configure nodejs tutorial. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "how to configure nodejs tutorial". Next, please follow the editor to study!

See version

Node-version

Helloworld.js

Var http = require ('http'); server = http.createServer (function (req, res) {res.writeHeader (200,{ "Content-Type": "text/plain"}); res.end ("Hello World\ n");}) server.listen (8000); console.log ("httpd start @ 8000")

Run on DOS

Node helloworld.js

Enter the url in explorer

Http://localhost:8000/

You will see "Hello World"

Npm:

Node.js+express.js+monent.js

Mongodb+mongoose

Jade

Bower:

JQuery

Bootstrap

Npm install express jade moment mongoose mongodb

Q: error enoent stat

A: C:\ Users\ Administrator\ AppData\ Roaming\ create a npm folder in this directory

App.js (entry file)

Var express = require ('express') var port = process.env.PORT | | 3000var app = express () app.set (' views','. / views') App.set ('view engine',' jade') app.listen (port) console.log ('server started') / / index pageapp.get (' /', function (req, res) {res.render ('index', {title:' index page'})}) / / detail pageapp.get ('/ movie/:id', function (req, res) {res.render ('detail' {title: 'detail page'})) / / admin (add) pageapp.get (' / admin/movie', function (req, res) {res.render ('admin', {title:' admin page'})}) / / list pageapp.get ('/ admin', function (req, res) {res.render ('list') {title: 'list page'})})

Index.jade, detail.jade, admin.jade, list.jade

Doctypehtml head meta (charset= "utf-8") title # {title} body H2 # {title}

Dos

Node app.js

See on explorer

Index page: http://localhost:3000detail page: http://localhost:3000/movie/1admin(add) page: http://localhost:3000/admin/movielist page: http://localhost:3000/admin

-

Install bower (global global)

Npm install bower-g

Install bootstrap (dependent on jquery)

Bower install bootstrap

A: Bower: ENOGIT git is not installed or not in the PATH

Q: install git

Npm install body-parser

Q:

(like bodyParser) is no longer bundled with Express and must be installed separately.

A: http://www.tuicool.com/articles/vaiyMb

Var bodyParser = require ('body-parser'); / / parse application/x-www-form-urlencodedapp.use (bodyParser.urlencoded ({extended: false})) / / parse application/jsonapp.use (bodyParser.json ()) npm install underscore

Q: errno:10061 was unable to connect because the target computer actively refused.

Q: cannot find module 'regexp-clone'/'sliced'/'mpath'/'ms'/'mquery'...

A:

Npm install regexp-clone sliced mpath ms mquery hooks mpromise muri

The above are all mongoose installation packages, probably due to the failure to install mongoose properly.

At this point, the study on "how to configure nodejs tutorial" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report