Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用git+为存储库安装纱线;我不在詹金斯工作_Node.js_Reactjs_Jenkins_Npm_Yarnpkg - Fatal编程技术网

Node.js 使用git+为存储库安装纱线;我不在詹金斯工作

Node.js 使用git+为存储库安装纱线;我不在詹金斯工作,node.js,reactjs,jenkins,npm,yarnpkg,Node.js,Reactjs,Jenkins,Npm,Yarnpkg,我试图在Jenkins上配置我的项目,这样每次提交都会导致自动生成。 当我使用Jenkins NodeJS脚本运行Thread install时,它会拒绝安装从git存储库导入的依赖项。我是这样做的 "some-component": "git+https://bitbucket.org/owner/repo.git" 它显示以下错误: error Command failed. Exit code: 128 Command: git Arguments: clone git+https://

我试图在Jenkins上配置我的项目,这样每次提交都会导致自动生成。 当我使用Jenkins NodeJS脚本运行
Thread install
时,它会拒绝安装从git存储库导入的依赖项。我是这样做的

"some-component": "git+https://bitbucket.org/owner/repo.git"
它显示以下错误:

error Command failed.
Exit code: 128
Command: git
Arguments: clone git+https://bitbucket.org/owner/repo.git
Output:
fatal: destination path 'some path' already exists and is not an empty directory.
error Command failed with exit code 1.
如果文件为空,则显示以下错误

error Couldn't find the binary git
error Command failed with exit code 1.
尽管相同的
纱线安装
在IDE(例如VS code)上运行良好

我使用以下代码在Jenkins上的NodeJS脚本中执行
纱线安装

var exec = require('child_process').exec,
    child;

 child = exec('yarn install ',
 function (error, stdout, stderr) {
     console.log('stdout: ' + stdout);
     console.log('stderr: ' + stderr);
     if (error !== null) {
          console.log('exec error: ' + error);
     }
 });

在docker容器中尝试从git存储库添加包时,我收到了相同的错误

$ yarn add git+https://git@github.com/username/some_repo.git
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
我认为纱线试图解析我使用的url有问题;您可以使用不同的变体(如https、git+https、ssh)。 来看看,我所在的docker容器,没有安装git。 因此,当Thread承担检索git存储库的任务时,它没有git二进制文件

解决方案:在docker容器中安装git

希望即使我的解决方案的上下文不同(我在docker容器中,而不是在Jenkins工作中),如果您确保在Jenkins工作中可以访问
git
,它可能会帮助解决您的问题


您可以通过运行git--version来测试这一点,并且应该有一个版本输出来证明您有或没有git可用。

在docker容器中尝试从git存储库添加包时,我收到了相同的错误

$ yarn add git+https://git@github.com/username/some_repo.git
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
我认为纱线试图解析我使用的url有问题;您可以使用不同的变体(如https、git+https、ssh)。 来看看,我所在的docker容器,没有安装git。 因此,当Thread承担检索git存储库的任务时,它没有git二进制文件

解决方案:在docker容器中安装git

希望即使我的解决方案的上下文不同(我在docker容器中,而不是在Jenkins工作中),如果您确保在Jenkins工作中可以访问
git
,它可能会帮助解决您的问题

您可以通过运行
git--version
来测试这一点,并且应该有一个版本输出来证明您有或没有git可用