• create a nodejs npm package


    1. create a folder named m1

    2. run command: npm init, this will create the package.json file

    3. create a lib folder using command: mkdir lib

    4. create index.js using : touch index.js

    5. run command : vim index.js , writing following content into it

    module.exports=function(){
        this.hi=function(){
            console.log('hi in index');
        }
    
        console.log('index file in m1');
    
    }

    6. type :w :q to save and quit editing mode

    7. To install m1 module to your project  , you can use command: npm install ../m1

    8. To visit your module code 

    var ma1=require('../m1');// require('../m1/lib/a');
    var ma1ins=new ma1();
    ma1ins.hi();

    reference:

    http://nqdeng.github.io/7-days-nodejs/#2.2.1

  • 相关阅读:
    继承
    对象与类
    反射
    I/O流
    字符串
    Map的entrySet()方法
    接口与内部类
    Git Usage Summary
    HTML(5)
    毕业设计:下载
  • 原文地址:https://www.cnblogs.com/zyip/p/4370370.html
Copyright © 2020-2023  润新知