Error "not found" using Yarn Berry
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 ํด๊ฒฐ ํ์ จ๋์ง ๋ชจ๋ฅด๊ฒ ๋ค์!
์ด ๊ธ์ ๋ณด์๋ ํ๊ตญ์ธ๋ค์ CI/CD ํ๊ฒฝ์์๋ yarn berry๋ฅผ ์ฐ๊ณ ๊ณ์ค ๊ฐ๋ฅ์ฑ์ด ๋์๋ฐ, ํ์ฌ chromatic-cli์์ yarn berry๋ฅผ ์ง์ํ์ง ์๊ธฐ ๋๋ฌธ์ CI/CD ์คํฌ๋ฆฝํธ์์ yarn ์ค์ ์ nodeLinker๋ฅผ node-modules๋ก ๋ณ๊ฒฝํด์ฃผ์ธ์.
# yarn ์ค์ job ์ฝ๋์ ์๋ ๋ช
๋ น์ด๋ฅผ ์ถ๊ฐํฉ๋๋ค.
yarn config set nodeLinker "node-modules"
@InSeong-So ๋๋ถ์ ํด๊ฒฐํ์ด์! ๊ฐ์ฌํฉ๋๋ค ๐๐ผ ๐๐ผ
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.
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