Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "not found" using Yarn Berry #578

Closed
saseungmin opened this issue May 26, 2022 · 4 comments
Closed

Error "not found" using Yarn Berry #578

saseungmin opened this issue May 26, 2022 · 4 comments

Comments

@saseungmin
Copy link

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
@InSeong-So
Copy link

@saseungmin 해결 하셨는지 모르겠네요!

이 글을 보시는 한국인들은 CI/CD 환경에서도 yarn berry를 쓰고 계실 가능성이 높은데, 현재 chromatic-cli에서 yarn berry를 지원하지 않기 때문에 CI/CD 스크립트에서 yarn 설정 시 nodeLinker를 node-modules로 변경해주세요.

관련 링크

# yarn 설정 job 코드에 아래 명령어를 추가합니다.
yarn config set nodeLinker "node-modules"

@Kihyun92
Copy link

Kihyun92 commented Dec 8, 2022

@InSeong-So 덕분에 해결했어요! 감사합니다 👍🏼 👍🏼

@domarmstrong
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants