GitHub Action中的npm install失败,并显示"ENOENT:no such file or directory".-在其他地方工作正常 [英] npm install in GitHub Action fails with "ENOENT: no such file or directory" - Works fine elsewhere

查看:334
本文介绍了GitHub Action中的npm install失败,并显示"ENOENT:no such file or directory".-在其他地方工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用GitHub Actions替换我们的Drone CI安装.

到目前为止,我的动作工作流程可归结为以下 .github/workflows/ci.yml 文件:

 <代码>于:[推送,pull_request]名称:CI职位:测试:运行:ubuntu-latest脚步:-名称:结帐用途:actions/checkout @ v2-名称:安装节点用途:actions/setup-node @ v1和:节点版本:"13.x"-名称:安装依赖项运行:npm install 

日志本身以一连串的 npm WARN TAR ENOENT出现:没有这样的文件或目录以及下面的截断列表.

  2020-04-29T21:15:31.7899082Z npm安装npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/acorn-26d8ba97/dist/acorn.js.map"npm WARN TAR ENOENT:没有此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/register.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/repl.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/rewriter.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/tslint-c216b578/LICENSE"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/eslint-cd3dbe58/LICENSE"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/eslint-cd3dbe58/README.md"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/typescript-b4b55d18/lib/diagnosticMessages.generation.json"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/jquery-1794793b/dist/jquery.min.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/lodash-05c1df31/fp/_convertBrowser.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/lodash-70e4a396/fp/_convertBrowser.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/lodash-79f5ae17/fp/_convertBrowser.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/lodash-e49b02f6/fp/_convertBrowser.js"npm WARN TAR ENOENT:无此类文件或目录,请打开"/home/runner/work/project/project/node_modules/.staging/lodash-16fa050d/fp/_convertBrowser.js" 

我在网上找到的建议是 rm package-lock.json ,但这不是可接受的解决方案,因为我需要使用已锁定的依赖项的确切版本来测试我们的代码.

此外,我认为我们的package-lock.json文件没有任何问题,因为在本地和我们的Drone CI安装中,它仍然仍然是 npm install .

解决方案

在漫长的等待中,我在这里找到了解决方案:

安装使用GitHub Actions从私有GitHub存储库中获取一个npm模块

 -使用:actions/checkout @ v2和:持久凭证:false-使用:actions/setup-node @ v1和:节点版本:12.x-运行:git config --global url." https://$ {{secrets.PAT}} @ github.com/".insteadOf ssh://git@github.com/-运行:npm ci... 

我基本上自己尝试了所有这些操作,但是最重要的部分丢失了:

 具有:持久凭证:false 

actions/checkout @ v2 默认情况下会混淆Git的某些设置,并阻止 insteadOf 正常工作.

I am currently working on replacing our Drone CI installation with GitHub Actions.

The Action Workflow I have so far boils down to the following .github/workflows/ci.yml file:

on: [ push, pull_request ]

name: CI
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install Node
        uses: actions/setup-node@v1
        with:
          node-version: '13.x'

      - name: Install Dependencies
        run: npm install

The log itself comes out as a long series of npm WARN tar ENOENT: no such file or directory ala the truncated list below.

2020-04-29T21:15:31.7899082Z npm install
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/acorn-26d8ba97/dist/acorn.js.map'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/register.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/repl.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/coffeescript-acee515b/lib/coffee-script/rewriter.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/tslint-c216b578/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/eslint-cd3dbe58/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/eslint-cd3dbe58/README.md'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/typescript-b4b55d18/lib/diagnosticMessages.generated.json'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/jquery-1794793b/dist/jquery.min.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-05c1df31/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-70e4a396/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-79f5ae17/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-e49b02f6/fp/_convertBrowser.js'
npm WARN tar ENOENT: no such file or directory, open '/home/runner/work/project/project/node_modules/.staging/lodash-16fa050d/fp/_convertBrowser.js'

The advice I have found online is to rm package-lock.json but that's not an acceptable solution as I need to test our code with the exact versions of our dependencies we have locked.

Further, I don't believe there is anything wrong with our package-lock.json file to begin with because it still npm install 's as expected both locally and on our Drone CI installation.

解决方案

At long wait, I found the solution here:

Install an npm module from a private GitHub repository using GitHub Actions

      - uses: actions/checkout@v2
        with:
          persist-credentials: false
      - uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - run: git config --global url."https://${{ secrets.PAT }}@github.com/".insteadOf ssh://git@github.com/
      - run: npm ci
      ...

I had tried basically all of this on my own but the most important part was missing:

        with:
          persist-credentials: false

actions/checkout@v2 will by default mess with some settings for Git and prevent insteadOf from working properly.

这篇关于GitHub Action中的npm install失败,并显示"ENOENT:no such file or directory".-在其他地方工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆