gpt4 book ai didi

elm - 在 github 操作中使用 elm-test

转载 作者:行者123 更新时间:2023-12-05 00:02:05 25 4
gpt4 key购买 nike

每当将提交推送到主分支时,我想使用 git hub 操作来测试和构建我的 elm 包,为此我的操作 .yml 文件如下所示

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失败并显示

/usr/local/bin/elm-test -> /usr/local/lib/node_modules/elm-test/bin/elm-test

> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a1f161713570e1557100915143a4b5449544a" rel="noreferrer noopener nofollow">[email protected]</a> 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: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ee8fdebf8ebe0fafdcebca0bfa0bc" rel="noreferrer noopener nofollow">[email protected]</a> (node_modules/elm-test/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b5d485e4d5e554f487b09150a1509" rel="noreferrer noopener nofollow">[email protected]</a>: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f3969f9e9ade879cde99809c9db3c2ddc0ddc3" rel="noreferrer noopener nofollow">[email protected]</a> install: `binwrap-install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9afff6f7f3b7eef5b7f0e9f5f4daabb4a9b4aa" rel="noreferrer noopener nofollow">[email protected]</a> 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 hub 操作中安装 elm-test 有什么建议吗?

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

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

最佳答案

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

npm install -D elm-test

您可能还想将 node_modules 添加到 .gitignore 以忽略 npm 的安装文件夹。

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

来调用它
./node_modules/elm-test/bin/elm-test

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

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

关于elm - 在 github 操作中使用 elm-test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60058556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com