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

create a nodejs npm package的更多相关文章

  1. npm安装socket.io时报错的解决方法(npm WARN enoent ENOENT: no such file or directory, open '/usr/local/nodejs/bin/package.json')

    执行 npm install socket.io安装时报错: [root@WEB node_modules]# npm install socket.ionpm WARN enoent ENOENT: ...

  2. [WASM Rust] Create and Publish a NPM Package Containing Rust Generated WebAssembly using wasm-pack

    wasm-pack is a tool that seeks to be a one-stop shop for building and working with Rust generated We ...

  3. ubuntu14.04下nodejs + npm + bower的安装、调试和部署

      1. 简介 本文介绍ubuntu14.04下nodejs+npm+bower的安装.调试和部署 参考文档 https://docs.npmjs.com/getting-started https: ...

  4. [NPM + React] Prepare a Custom React Hook to be Published as an npm Package

    Before we publish our package, we want to make sure everything is set up correctly. We’ll cover vers ...

  5. AX7: CREATE AN AUTOMATED TEST PACKAGE\MODEL

    AX7: CREATE AN AUTOMATED TEST PACKAGE\MODEL It’s really important for a stable solution the use of a ...

  6. Windows环境下的NodeJS+NPM+Bower安装配置步骤

    Windows下的NodeJS安装是比较方便的(v0.6.0版本之后,支持windows native),只需要登陆官网(http://nodejs.org/),便可以看到首页的“INSTALL”按钮 ...

  7. Windows 系统下设置Nodejs NPM全局路径

    Windows下的Nodejs npm路径是appdata,很不爽,想改回来,但是在cmd下执行以下命令也无效 npm config set cache "D:\nodejs\node_ca ...

  8. [Node.js] Configuring npm package.json scripts

    With a node package manager's (npm) package.json script property, you can preconfigure common tasks ...

  9. 【前端】Ubuntu16下nodejs+npm+vue环境配置

    笔者最近在学习vue.js,不过一直都是在runoob上面各种尝试.今天笔者在本机(Ubuntu16.04)尝试部署了nodejs+npm+vue开发环境,接下来将尽可能详细的讲述安装过程,帮助新人少 ...

随机推荐

  1. Prototype Pattern

  2. sparsity and density

    转:http://searchdatamanagement.techtarget.com/definition/sparsity-and-density 查了一下定义,以免会写错 Sparsity a ...

  3. Ubuntu Tweak (linux下的优化大师)

    Ubuntu Tweak 是中国人开发的一款专门为Ubuntu准备的配置.调整工具,它类似与compiz,但是界面更友好. 下面是安装命令: 第一步:添加tweak源 sudo add-apt-rep ...

  4. vbox安装 ubuntu server 后 安装增强包

    用vbox安装虚拟机系统如果不装增强包, 有很多东西就有点不好用-用vbox安装ubuntu server时,点击菜单中的安装增强功能.因为ubuntu server版本没有ui,所以不能很方便滴找到 ...

  5. Gradle入门实战(Windows版)

    Installation Gradle runs on all major operating systems and requires only a Java JDK or JRE version ...

  6. [转]删除MSSQL所有的约束及表格

    --删除所有约束.表.视图等SQL脚本 --############################################### --删除所有外键约束 --################# ...

  7. C#使用DotNetZip对zip压缩包进行添加删除操作

    参考:http://stackoverflow.com/questions/9855155/how-can-i-delete-a-directory-in-a-zip-file-using-net D ...

  8. vue+elementUI封装的时间插件(有起始时间不能大于结束时间的验证)

    vue+elementUI封装的时间插件(有起始时间不能大于结束时间的验证): html: <el-form-item label="活动时间" required> & ...

  9. mysql 修改数据类型

    只修改列的数据类型的方法: 通常可以写成 alter table 表名 modify column 列名 新的列的类型 例如:student表中列sname的类型是char(20),现在要修改为var ...

  10. sharePoint中简单的父页面跳转子页面代码!

    1,SharePoint中挺简单的一个父页面跳转到子页面的Js代码!常常用到,每次都到以前的项目中去找代码,挺麻烦! (1)父页面代码. function imgAddParentclick() { ...