chromatic-cli icon indicating copy to clipboard operation
chromatic-cli copied to clipboard

Error "not found" using Yarn Berry

Open saseungmin opened this issue 3 years ago โ€ข 4 comments

Hi! there I'm using yarn berry(v3.2.0) package manager. When executing a command in npm, an error occurs that cannot find the command.

It works normally when I change the command that runs in npm to yarn.

// before
npm run build-storybook

// after
yarn run build-storybook

Who knows how to use github action using "yarn berry"?

I'd appreciate it if anyone could give me some advice. ๐Ÿ™‡โ€โ™‚๏ธ

Here is my chromatic.yml and github action log

name: 'Chromatic Publish'

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Use Node.js 16.14.2
        uses: actions/setup-node@v2
        with:
          node-version: "16.14.2"
      - run: yarn install --immutable
      - uses: chromaui/action@v1
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
          skip: 'dependabot/**'
Chromatic CLI v6.5.4
https://www.chromatic.com/docs/cli

Authenticating with Chromatic
    โ†’ Connecting to https://index.chromatic.com
Authenticated with Chromatic
    โ†’ Using project token '********cd95'
Retrieving git information
Retrieved git information
    โ†’ Commit '545e[7](https://github.com/kasa-network/kasa-web/runs/6609617522?check_suite_focus=true#step:5:8)aa' on branch 'FE-457'; no ancestor found
Collecting Storybook metadata
Collected Storybook metadata
    โ†’ ; no supported addons found
Building your Storybook
    โ†’ Running command: npm run --silent build-storybook -- --output-dir /tmp/chromatic--1905-1zg5R4T0L17f
The CLI tried to run your build-storybook script, but the command failed. This indicates a problem with your Storybook. Here's what to do:

- Check the Storybook build log printed below.
- Run npm run build-storybook or yarn build-storybook yourself and make sure it outputs a valid Storybook by opening the generated index.html in your browser.
- Review the build-storybook CLI options at https://storybook.js.org/docs/configurations/cli-options/#for-build-storybook

Command failed with exit code 127: npm run --silent build-storybook -- --output-dir /tmp/chromatic--1905-1zg5R4T0L17f

โ„น Spawn settings:
{
  "client": "npm",
  "clientVersion": "[8](https://github.com/kasa-network/kasa-web/runs/6609617522?check_suite_focus=true#step:5:9).5.0",
  "nodeVersion": "v16.14.2",
  "platform": "linux",
  "command": "npm",
  "clientArgs": [
    "run",
    "--silent"
  ],
  "scriptArgs": [
    "build-storybook",
    "--",
    "--output-dir",
    "/tmp/chromatic--1[9](https://github.com/kasa-network/kasa-web/runs/6609617522?check_suite_focus=true#step:5:10)05-1zg5R4T0L[17](https://github.com/kasa-network/kasa-web/runs/6609617522?check_suite_focus=true#step:5:18)f"
  ]
}

โ„น Storybook build output:
/home/runner/work/kasa-web/kasa-web/build-storybook.log

sh: 1: build-storybook: not found
    โ†’ Command failed: npm run --silent build-storybook -- --output-dir /tmp/chromatic--[19](https://github.com/kasa-network/kasa-web/runs/6609617522?check_suite_focus=true#step:5:20)05-1zg5R4T0L17f




Error: non-zero exit code

saseungmin avatar May 26 '22 16:05 saseungmin

@saseungmin ํ•ด๊ฒฐ ํ•˜์…จ๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ๋„ค์š”!

์ด ๊ธ€์„ ๋ณด์‹œ๋Š” ํ•œ๊ตญ์ธ๋“ค์€ CI/CD ํ™˜๊ฒฝ์—์„œ๋„ yarn berry๋ฅผ ์“ฐ๊ณ  ๊ณ„์‹ค ๊ฐ€๋Šฅ์„ฑ์ด ๋†’์€๋ฐ, ํ˜„์žฌ chromatic-cli์—์„œ yarn berry๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— CI/CD ์Šคํฌ๋ฆฝํŠธ์—์„œ yarn ์„ค์ • ์‹œ nodeLinker๋ฅผ node-modules๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”.

๊ด€๋ จ ๋งํฌ

# yarn ์„ค์ • job ์ฝ”๋“œ์— ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
yarn config set nodeLinker "node-modules"

InSeong-So avatar Sep 14 '22 08:09 InSeong-So

@InSeong-So ๋•๋ถ„์— ํ•ด๊ฒฐํ–ˆ์–ด์š”! ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๐Ÿ‘๐Ÿผ ๐Ÿ‘๐Ÿผ

Kihyun92 avatar Dec 08 '22 10:12 Kihyun92

Changing yarn to not use pnp is not really a solution. The command should use yarn not npm if the package manager for the project is yarn.

domarmstrong avatar Mar 13 '23 10:03 domarmstrong

I've found there is actually quite an easy fix for this. Add a build command to your package.json and prefix it with yarn.

package.json

`"build-stories": "yarn build-storybook ..."`

Then in the action file specify that as the build script:

.github/workflows/chromatic.yml

with:
  buildScriptName: build-stories

domarmstrong avatar Mar 13 '23 12:03 domarmstrong