简体   繁体   English

强制项目使用 Yarn 但不使用 npm

[英]Force project to use Yarn but not npm

As a team practice, I would like to force my teammate to use yarn install/ run but not npm install/ run .作为团队实践,我想强迫我的队友使用yarn install/ run而不是npm install/ run

Is it possible to force a package.json 's dependency be installed only via yarn install or package.json 's script be run only via yarn run ? Is it possible to force a package.json 's dependency be installed only via yarn install or package.json 's script be run only via yarn run ?

If it cannot be done, can I at least get a warning when using npm install ?如果无法完成,我至少可以在使用npm install时收到警告吗?


Again, this is only to align the team practice, so that reduces the possibility of error/ problem produced during dev/ops.同样,这只是为了调整团队实践,从而减少在开发/运营期间产生错误/问题的可能性。 Thanks谢谢

One of the way I can think of is CI can set a rules to detect if there is new file package-lock.json file being created, make the build fail.我能想到的一种方法是 CI 可以设置规则来检测是否有新文件package-lock.json正在创建文件,使构建失败。 The developer will then realized he made a mistake since his build failed.然后开发人员会意识到他犯了一个错误,因为他的构建失败了。

Alternatively you can also rely on husky pre-commit hook , which essentially runs a command to check if package-lock.json existed everytime developer trying to run git commit .或者,您也可以依赖husky pre-commit hook ,它本质上运行一个命令来检查package-lock.json存在于每次开发人员尝试运行git commit

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

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