zoukankan      html  css  js  c++  java
  • NodeJs环境配置

    *

    1,下载路径
    https://nodejs.org/en/download/

    2,安装 express(之前用npm install -g express,一直提示出错,然后查资料说nodejs如果是4以上,
    应该用express-generator)

    D:ResourcesNODEJS odejs>npm uninstall -g express
    npm WARN uninstall not installed in D:ResourcesNODEJS odejs ode_modules: "express"

    D:ResourcesNODEJS odejs>npm install -g express-generator
    D:ResourcesNODEJS odejsexpress -> D:ResourcesNODEJS odejs ode_modulesexpress-generatorinexpress
    express-generator@4.13.4 D:ResourcesNODEJS odejs ode_modulesexpress-generator
    ├── sorted-object@2.0.0
    ├── mkdirp@0.5.1 (minimist@0.0.8)
    └── commander@2.7.1 (graceful-readlink@1.0.1)

    D:ResourcesNODEJS odejs>express -V
    4.13.4

    //创建helloworld的项目
    D:ResourcesNODEJS odejs>express helloworld

    create : helloworld
    create : helloworld/package.json
    create : helloworld/app.js
    create : helloworld/public/javascripts
    create : helloworld/public/images
    create : helloworld/public/stylesheets
    create : helloworld/public/stylesheets/style.css
    create : helloworld/routes
    create : helloworld/routes/index.js
    create : helloworld/routes/users.js
    create : helloworld/public
    create : helloworld/views
    create : helloworld/views/index.jade
    create : helloworld/views/layout.jade
    create : helloworld/views/error.jade
    create : helloworld/bin
    create : helloworld/bin/www

    *************helloworld.js//////
    var http = require("http");
    http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World");
    response.end();
    }).listen(8888);
    console.log("nodejs start listen 8888 port!");

    ****************

    D:ResourcesNODEJS odejs>cd helloworld

    D:ResourcesNODEJS odejshelloworld>node helloworld.js
    nodejs start listen 8888 port!


     打开地址http://127.0.0.1:8888/
    发现输出 :
    Hello World

    来自 <http://www.cnblogs.com/pigtail/archive/2013/01/08/2850486.html>

    *****************
    1,cmd窗口,输入node,回车,输入"console.log("hello")",可以简单测试node.js

    *

    有问题在公众号【清汤袭人】找我,时常冒出各种傻问题,然一通百通,其乐无穷,一起探讨


  • 相关阅读:
    apache 问题 You don't have permission to access /test.php on this server 解决方法
    setTimeout和setInterval实现定时器的区别
    视图Ext.Viewport和窗口Ext.Window用法
    JavaScript设置Cookie
    布局Layout
    html中select标签刷新后不回到默认值而是保持之前选择值
    设置session失效的几种方法
    面板Ext.Panel使用
    树TreePanel
    让html元素随浏览器的大小自适应垂直居中
  • 原文地址:https://www.cnblogs.com/qingmaple/p/6096823.html
Copyright © 2011-2022 走看看