chromaui/chromatic-cli

"Found invalid package.json" just started appearing this morning

Opened this issue · 10 comments

dep commented

Very strange as we didn't change anything in our monorepository but this morning all of our Chromatic tasks are failing with the same error:

Run chromaui/action@v1
  with:
    projectToken: ***
    storybookBuildDir: applications/react/modern/template/storybook-static/src
    exitZeroOnChanges: true
✖ Invalid package.json
Found invalid package.json at /home/runner/work/Box/package.json
Make sure this is a valid Node.js package file, is readable, and contains a "scripts" block.

I wonder if there was some sort of transitive dependency bug introduced?

dep commented

Looks like the Action was update 4 hours ago: https://github.com/chromaui/action - Seems like it might've introduced a regression. Our root-of-repo package.json doesn't need a scripts tag. Instead, it uses nx to execute scripts within the child applications' package.json.

dep commented

For what it's worth adding an empty scripts tag to my root package.json fixed the issue:

{
  "name": "foo",
  "scripts": {},
  ...
}

We are experiencing the same issue for the last 2 days. Unfortunately, your solution @dep is not resolving it for us so hopefully there will be an update in the action itself that will help in our case.

@dep thank you for reporting this issue. We are investigating this. Can you provide us a small reproduction that we can test the action against?

dep commented

Ours is a monorepository, so we have a package.json that sits at the root of the repo (with no scripts definition).

We then have a folder system like this:

root: package.json
  applications/react/app-1
      - package.json with "scripts" defined
  applications/react/app-2
      - package.json with "scripts" defined

Then each "app" has its own github action with the following step:

- uses: chromaui/action@v1
  with:
    projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
    storybookBuildDir: 'applications/react/app-1/storybook-static/src'
    exitZeroOnChanges: true

I hope this helps reproduce

Thank you so much! We are looking into this and hope to have a resolution soon!

hello @thafryer
is there any progress on this issue
we dont use scripts in our package.json
is there a way to run the commande without having scripts filed in the package.json file ?

Same issue here. No scripts in package.json for now we will add.

We're having the same issue. We already have a scripts entry in our package.json, so adding an empty one is no option for us.

node: 20.11.1
pnpm: 8.14.0
storybook: 8.0.8
chromatic: 11.3.0
@chromatic-com/storybook: 1.3.3
uses: chromaui/action@v11
with:
  autoAcceptChanges: main
  projectToken: ...
  storybookBuildDir: packages/storybook/src/

The same issue arrises when we use storybookBuildDir: packages/storybook/dist/ or storybookBuildDir: packages/storybook/

I called too soon. Our probleam was that the storybook build artifact was unavailable. Hopefully this gives people insight in resolving their issue.