Use npm Registry to Restric Installing Client

Background

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

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

Some approaches make use of preinstall hook. See:npm

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

Custom npm registry

Maybe we can do it by custom npm registry.this

See npm-registry-proxy for source codes.code

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

Result

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

  • 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.requests

相關文章
相關標籤/搜索