首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在git集线器动作中使用elm测试

在git集线器动作中使用elm测试
EN

Stack Overflow用户
提问于 2020-02-04 13:32:39
回答 2查看 540关注 0票数 2

我想使用一个git集线器操作来测试和构建我的elm包,只要提交到主分支,我的动作.yml文件如下所示

代码语言:javascript
复制
name: CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup Elm environment
      uses: JorelAli/setup-elm@v1
      with:
        # Version of Elm to use. E.g. 0.19.1
        elm-version: 0.19.1
    - run: |
        sudo npm install -g elm-test # this fails
        elm-test
        elm make

为了进行测试,我想使用elm-test,它可以通过npm安装,但是命令sudo npm install -g elm-test失败了

代码语言:javascript
复制
/usr/local/bin/elm-test -> /usr/local/lib/node_modules/elm-test/bin/elm-test

> elmi-to-json@1.3.0 install /usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json
> binwrap-install

ERR Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
    at Object.mkdirSync (fs.js:823:3)
    at /usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:46:10
    at new Promise (<anonymous>)
    at untgz (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:21:10)
    at binstall (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/binstall.js:11:12)
    at install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/install.js:20:10)
    at Object.install (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/index.js:14:14)
    at Object.<anonymous> (/usr/local/lib/node_modules/elm-test/node_modules/binwrap/bin/binwrap-install:18:9)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  errno: -13,
  syscall: 'mkdir',
  code: 'EACCES',
  path: '/usr/local/lib/node_modules/elm-test/node_modules/elmi-to-json/unpacked_bin'
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/elm-test/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elmi-to-json@1.3.0 install: `binwrap-install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elmi-to-json@1.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-02-03T17_50_06_232Z-debug.log

关于如何在git操作中安装elm-test,有什么建议吗?

编辑:如果没有sudo,错误将变成

代码语言:javascript
复制
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-02-04T13_41_34_534Z-debug.log
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-02-04 19:23:34

感谢@toastal的评论,我找到了另一个解决方案。也就是说,使用npm设置一个npm文件,然后使用命令将elm-test作为依赖项添加

代码语言:javascript
复制
npm install -D elm-test

此外,您可能希望将node_modules添加到您的.gitignore中,以忽略npm的安装文件夹。

然后,在yml文件中,只需运行命令npm install和安装elm-test。然后你就可以用

代码语言:javascript
复制
./node_modules/elm-test/bin/elm-test

我的yml文件现在看起来如下

代码语言:javascript
复制
name: Tests

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup Elm environment
      uses: JorelAli/setup-elm@v1
      with:
        # Version of Elm to use. E.g. 0.19.1
        elm-version: 0.19.1
    - name: install npm dependencies
      run: npm install
    - name: Test
      run: ./node_modules/elm-test/bin/elm-test
    - name: check documentation
      run: |
        elm make --docs=docs.json
        rm docs.json
票数 3
EN

Stack Overflow用户

发布于 2020-02-04 15:24:13

感谢@glennsl,我找到了一个解决方案:指定npm全局安装包的位置。因为运行该操作的运行程序没有访问/usr/local/lib的权限,所以无法在全局级别上安装任何东西。解决方案(如描述的这里)是将文件夹创建为“全局”安装文件夹,并配置npm来使用它。还必须将新文件夹添加到PATH环境变量中。

所以我的yml文件现在看起来像这样

代码语言:javascript
复制
name: CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup Elm environment
      uses: JorelAli/setup-elm@v1
      with:
        # Version of Elm to use. E.g. 0.19.1
        elm-version: 0.19.1
    - run: |
        mkdir ~/.npm-global
        npm config set prefix '~/.npm-global'
        PATH=~/.npm-global/bin:$PATH
        npm install -g elm-test
        elm-test
        elm make
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60058556

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档