[Node.js] Using npm link to use node modules that are "in progress"
It is some times convenient, even necessary, to make use of a module that you are working on before it has been published to the node package manager (npm). The npm link command makes this simple.
For example:

upper/index.js:
module.exports = function(str){
return str.toUpperCase();
}
packjson:
{
"name": "upper",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
user/index.js:
var upper = require('upper');
console.log(upper('hello world'));
In the user/index.js, we want to use upper module which is not published to the npm yet. Therefore, when we run the app, it will report the error:

Enable to test the module, we can use 'npm link':
- Locate upper folder and run:
npm link

It says that our node_modules links to this upper module.
[Notice:] You need to have package.json file when using 'npm link', because it uses its name to refering the module.
2. Go back to the user dir, use that upper dir:
cd ../user npm link upper
C:\Users\Answer1215\WebstormProjects\mean\npmlink\user\node_modules\upper -> C:\Users\Answer1215\AppData\Roaming\npm\node_modules\upper -> C:\Users\Answer1215\WebstormProjects\mean\n
pmlink\upper
It says that, our upper dir links to the system node_module's upper, then links to our user dir.
3. Now we can use this upper module.
[Notice:] Once you finish testing, you need to unlink this moduole! or it may cause problem
4. In the user dir:
npm unlink upper
More:
https://egghead.io/lessons/node-js-using-npm-link-to-use-node-modules-that-are-in-progress
[Node.js] Using npm link to use node modules that are "in progress"的更多相关文章
- 如何在CentOS 7上安装Node.js和npm
Node.js是一个跨平台的JavaScript运行时环境,允许在服务器端执行JavaScript代码.Node.js主要用于后端,但也作为全栈和前端解决方案而流行. npm,Node软件包管理器的缩 ...
- node.js的npm详解
一.什么是npm呢 npm(Node Package Manager,node包管理器)是node的包管理器,他允许开发人员在node.js应用程序中创建,共享并重用模块.模块就是可以在不同的项目中重 ...
- 安装node.js 和 npm 的完整步骤
vue 生命周期 1,beforeCreate 组件刚刚被创建 2,created 组件创建完成 3,beforeMount 挂载之前 4,mounted 挂载之后 5,beforeDestory 组 ...
- Windwos安装Node.js和npm的详细步骤
How to Install Node.js and NPM on Windows Node.js和npm 安装 Node.js 的时候会自动安装 npm ,并且 npm 就是 Node.js 的包管 ...
- 在Linux Mint上安装node.js和npm
1.安装Node.js 前端开发过程中,很多项目使用npm的http-server的模块来运行一个静态的服务器,我个人在Dell的笔记本上安装的是Linux Mint最新版本,所以想尝试一下在Linu ...
- 关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用
关于node.js和npm,cnpm的安装记录以及gulp自动构建工具的使用 工作环境:window下 在一切的最开始,安装node.js (中文站,更新比较慢http://nodejs.cn/) ...
- node.js的npm安装
我不打算引进node.js的npm安装,但发现node.js通过管理一些包npm实现,或给一个简短的npm. 1.npm什么 npm是一个node包管理和分发工具,已经成为了非官方的公布 ...
- Node.js入门 NPM
参考一 Node入门 七天学会NodeJS Node.js v4.2.4 手册 & 文档 Node.js 教程 node.js摸石头系列 从零开始学习node.js What is ...
- Node.js、npm、vue-cli 的安装配置环境变量
我安装node.js是为了学习vue,需要用到npm,所以就把node.js安装了,安装node.js会带有npm的安装. 在安装node.js之前,我们需要了解以下三个内容. npm: Nodejs ...
随机推荐
- poj2436,poj3659,poj2430
这两题都体现了dp的核心:状态 dp做多就发现,状态一设计出来,后面的什么都迎刃而解了(当然需要优化的还要动动脑筋): 先说比较简单的: poj2436 由题得知病毒种数<=15很小,于是我们就 ...
- LeetCode Minimum Size Subarray Sum (最短子序列和)
题意:给一个序列,找出其中一个连续子序列,其和大于s但是所含元素最少.返回其长度.0代表整个序列之和均小于s. 思路:O(n)的方法容易想.就是扫一遍,当子序列和大于s时就一直删减子序列前面的一个元素 ...
- 【转】Android底层库和程序
原文网址:http://blog.csdn.net/louiswangbing/article/details/6616202 Android底层库和程序 1. 本地实现的基本结构 Andro ...
- postgreSQL数据类型转换字符串和数值
1.将数值转成字符串类型 方法1:调用to_char(int, text)函数,int为要转换值,text为数值格式化模式,其中模式描述为: 模式 描述 9 带有指定数值位数的值 0 带前导零的值 ...
- show slave status中的log_file / log_pos
在MySQL的master-slave或dual master的架构中,我们经常使用show slave status命令来查看复制状态. 这里涉及几个重要的日志文件和位置: Master_Log_F ...
- 网站HTTP请求过程解析
网站性能优化中首要的一条就是要减少HTTP请求,那么为要减少HTTP请求呢?其实有些HTTP分析工具可以帮我们了解当浏览器请求一个资源时大致需要经历的哪些过程: 1 域名解析(DNS Lookup): ...
- 玩一个:可以显示任何xml树结构的xaml定义
学习中, 玩一玩. 效果如下.Xaml随后. <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentatio ...
- js中的new关键字都干了些什么?
new 操作符 在有上面的基础概念的介绍之后,在加上new操作符,我们就能完成传统面向对象的class + new的方式创建对象,在javascript中,我们将这类方式成为Pseudoclassic ...
- Java 开发@ JDBC链接SQLServer2012
下面请一字一句地看,一遍就设置成功,比你设置几十遍失败,费时会少得多. 首先,在连接数据库之前必须保证SQL Server 2012是采用SQL Server身份验证方式而不是windows身份验证方 ...
- android中OnItemClickListener的参数解释
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {} ...