简体   繁体   English

与“ npm install”类似的自定义CLI,它将在“ node_modules”以外的文件夹中安装库

[英]Custom CLI similar to “npm install” that will install libs in folder other than “node_modules”

I understand that "npm install" in NodeJS will actually install libraries into a folder called "node_modules". 我知道NodeJS中的“ npm install”实际上会将库安装到名为“ node_modules”的文件夹中。

I am actually wanting to achieve something similar but to use my own CLI instead (eg using commands like "myproject install" instead of "npm install") and then the libraries (proprietary ES6 source codes from my company's Enterprise Git Repo) will be installed into a specific folder (eg "myown_modules" rather than "node_modules"). 我实际上是想实现类似的目的,但是要改用我自己的CLI(例如,使用“ myproject install”之类的命令代替“ npm install”之类的命令),然后再安装库(我公司的Enterprise Git Repo的专有ES6源代码)放入特定的文件夹(例如“ myown_modules”而不是“ node_modules”)。

Question is, how do I achieve that, assuming that I want dependencies checking as well on the libraries that are going to be installed? 问题是,假设我也要对将要安装的库进行依赖项检查,我如何实现这一目标? Also, how do we control versions using own CLI? 另外,我们如何使用自己的CLI控制版本?

Use this repo and modify it to do what you want. 使用此存储库并对其进行修改以执行所需的操作。

You need to change the install folder and change the process with the name you want. 您需要更改安装文件夹,并使用所需名称更改过程。

NPM repo : https://github.com/npm/npm NPM回购: https : //github.com/npm/npm

OR : 要么 :

Create a bash script who will do npm install xxxx when you use myscript xxxx , so you can't change the node_modules with this. 创建一个bash脚本,当您使用myscript xxxx时将执行npm install xxxx myscript xxxx ,因此您不能使用此node_modules更改node_modules

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

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