[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 ...
随机推荐
- autofac 学习记录
builder.RegisterModule(new ConfigurationSettingsReader()); 需要注册上面一句才能读到.config里的节点,xml配置方式如下 <con ...
- UVA 1324 The Largest Clique 最大团(强连通分量,变形)
题意:给一个有向图,要求找出一些点,使得这些点中的任意点对,要么可以互通,要么单向可达. 思路:最低只要求单向可达即可,即a->b都可以算进去. 强连通分量内的点肯定是满足要求的,可以全选,但是 ...
- Java [leetcode 29]Divide Two Integers
题目描述: Divide two integers without using multiplication, division and mod operator. If it is overflow ...
- 精简版、GHOST版win7,arduino驱动安装失败的解决方法分享
arduino组件安装驱动不成功,总是提示系统找不到指定文件. 原因是因为精简版缺少了两个关键的系统文件,导致无法安装.mdmcpq.inf 和 usbser.sys 解决方案详见帖子http:// ...
- Jquery AutoComplete的使用方法实例
jquery.autocomplete详解 语法: autocomplete(urlor data, [options] ) 参数: url or data:数组或者url [options]:可选项 ...
- MySQL性能指标及计算方法
绝大多数MySQL性能指标可以通过以下两种方式获取: (1)mysqladmin 使用mysqladmin extended-status命令获得的MySQL的性能指标,默认为累计值.如果想了解当前状 ...
- HDU4614 Vases and Flowers 二分+线段树
分析:感觉一看就是二分+线段树,没啥好想的,唯一注意,当开始摆花时,注意和最多能放的比大小 #include<iostream> #include<cmath> #includ ...
- 单元测试工具之Xunit
在.NET开发中的单元测试工具之——xUnit.Net 原始出处 http://zhoufoxcn.blog.51cto.com/792419/1172320 在上一篇<在.NET开发中的单元 ...
- glassfish 一个bug重现
原文链接:https://java.net/jira/browse/GLASSFISH-21293?jql=project%20%3D%20GLASSFISH%20AND%20resoluti ...
- uva11732 strcmp() Anyone?
题意:给出多个字符串,两两配对,求总配对次数. 思路:如果两个字符串一样,ans=strlen(字符串)*2+2,如果不同,ans=公共前缀长度*2+1:用左儿子右兄弟建字典树.插入一个字符计算一次. ...