简体   繁体   English

如何在我的反应项目中使用 package.json 依赖项中的系统变量?

[英]How to use system variables in package.json dependencies in my react project?

In my react project, I am trying to install a private package using the git URL.在我的反应项目中,我正在尝试使用 git URL 安装私有 package。 I want to specify a branch name in the URL which will be dynamic.我想在 URL 中指定一个动态的分支名称。

In the package.json file, when I hardcode the branch name it works fine.package.json文件中,当我对分支名称进行硬编码时,它工作正常。

dependencies: {
    ...
    my-package: "git+https://<git-url-of-my-package>#develop",
    ...
}

The problem is when I use the variable, it does not work as expected.问题是当我使用该变量时,它不能按预期工作。

dependencies: {
    ...
    my-package: "git+https://<git-url-of-my-package>#$BRANCH_NAME",
    ...
}

I am not sure here how to pass the branch name dynamically and I need some help in understanding the same.我不确定如何动态传递分支名称,我需要一些帮助来理解它。

Note: I don't want to install <my-package> using another npm script.注意:我不想安装<my-package>使用另一个 npm 脚本。 I want to install it with other dependencies using npm-install .我想使用npm-install将它与其他依赖项一起安装。

Thanks in advance.提前致谢。

Check URL as dependency, You can specify tarball URL检查 URL 作为依赖项,您可以指定 tarball URL

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies https://docs.npmjs.com/cli/v7/configuring-npm/package-json#urls-as-dependencies

Check This also - Using the git urls with specific branch or commit version in package.json does not work - https://github.com/yWorks/svg2pdf.js/issues/102 Check This also - Using the git urls with specific branch or commit version in package.json does not work - https://github.com/yWorks/svg2pdf.js/issues/102

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

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