惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
B
Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
L
LangChain Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题

vivaxy's Blog

SameSite Cookies 解读 - vivaxy's Blog VSCode Conventional Commits 插件 - vivaxy's Blog VSCode Conventional Commits Extension - vivaxy's Blog How Babel Is Built - vivaxy's Blog 一步一步解码 PNG 图片 - vivaxy's Blog Babel 的工程化实现 - vivaxy's Blog 浏览器图像转换手册 - vivaxy's Blog Decoding A PNG Image with JavaScript Step by Step Comprehensive Image Processing on Browsers Alfred 4 Workflow Open in VSCode Git Tag And Push Git Tag 基于 Custom Elements 的组件化开发 - vivaxy's Blog JavaScript PNG 图片编码和解码 - vivaxy's Blog 如何在多个模块中共享异步数据 - vivaxy's Blog JavaScript 函数式编程初窥 - vivaxy's Blog 用纯 CSS 实现弹窗 - vivaxy's Blog 在浏览器中使用 JavaScript 模块 - vivaxy's Blog Karabiner Elements Hyper 改键设置 - vivaxy's Blog Levenshtein 距离 - vivaxy's Blog Levenshtein 距离 - vivaxy's Blog
Use npm Registry to Restric Installing Client
vivaxy · 2019-09-30 · via vivaxy's Blog

Background

npm and yarn are not sharing lock file. A lock file is necessary for maintaining the stability of the project.

How can we make sure the developers are using the same client in our project?

Some approaches make use of preinstall hook. See:

But this is not working when the project is an npm package. When an npm package publishing, npm publish will invoke preinstall hook too.

Custom npm registry

Maybe we can do it by custom npm registry.

See npm-registry-proxy for source codes.

We can add registry="https://npm-registry-proxy.vivaxy.now.sh/yarn/https%3A%2F%2Fregistry.npmjs.org%2F/" to .npmrc.

Result

In project .npmrc, we have registry="https://npm-registry-proxy.vivaxy.now.sh/yarn/https%3A%2F%2Fregistry.npmjs.org%2F/".

  • When using yarn add, dependencies installed successfully.
  • When using npm i, install error occurred.

It works fine. But when we publishing packages, PUT requests are not successfully forwarded to the target registry. It does not apply to npm packages as well.