$(npm bin)/hugo——环境生产/bin/bash:第136行:未知:未找到命令



我使用hugo和doks和gitlab与以下.gitlab-ci.yml

---
image: node:latest
variables:
HUGO_ENV: production
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- npm install
- npm install -g hugo
test:
stage: test
script:
- $(npm bin)/hugo --environment staging
artifacts:
paths:
- test
pages:
stage: deploy
script:
- $(npm bin)/hugo --environment production
artifacts:
paths:
- public

这个工作很好,直到上周,我得到这个错误,因为突然

$ $(npm bin)/hugo --environment production
/bin/bash: line 136: Unknown: command not found
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 1

有趣的是,没有变化

npm bin自npm 9.0.0-pre.0版本起已被删除(参见https://github.com/npm/cli/blob/latest/CHANGELOG.md)

你可以简单地替换

$(npm bin)/xyz

$(npm_bin.sh)/xyz   

其中npm_bin.sh必须在$PATH中,看起来像:

#!/bin/bash
echo ./node_modules/.bin
  1. 删除以下行

    - npm install -g hugo
    
  2. 根据我使用的主题建议更新package.json:

    ...
    "devDependencies": {
    ....
    "hugo-installer": ">=4.0.1",
    ....
    },
    "otherDependencies": {
    "hugo": "0.107.0"
    }
    
  3. 更新hugo的路径如下

    ./node_modules/.bin/hugo/hugo --environment production
    

相关内容

最新更新