简体   繁体   English

如何模仿我的库是节点模块而不上传到NPM?

[英]How to imitate my library is a node module without uploading to the NPM?

If I'm developing a library which work is based a lot around of current working directory and the filesystem generally, a lot of paths resolution, and I want to see how it will behave when will be installed as a node module, I don't want to get unexpected results when I'll upload it to the npm.如果我正在开发一个库,它的工作通常基于当前工作目录和文件系统,很多路径解析,我想看看它在作为节点模块安装时的行为,我不当我将它上传到 npm 时,不想得到意想不到的结果。 How do I test my library behavior pretending it's a node module?如何假装它是节点模块来测试我的库行为? Is placing its folder in node_modules enough?将其文件夹放在node_modules中是否足够?

Make a local package and install it everywhere:制作一个本地 package 并将其安装在任何地方:

$ npm pack

it will generate a zipped file, so you can copy somewhere and install it.它将生成一个压缩文件,因此您可以在某处复制并安装它。

// another project
$ npm install /path/to/pack

Resources: npm pack , Add local package资源: npm包添加本地package

Absolutely you can use npm link too.当然,您也可以使用npm link link关联

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM