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 Error: Cannot find module '@changesets/changelog-github' #238

Closed
maximveksler opened this issue Dec 5, 2022 · 5 comments
Closed

Comments

@maximveksler
Copy link

maximveksler commented Dec 5, 2022

I have created a simple github action called .github/workflows/release.yml

name: Release

on:
  push:
    branches:
      - master

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          
      - uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Install Dependencies
        run: yarn

      - name: Create Release Pull Request
        uses: changesets/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

My .changeset/config.json is set to the following

{
  "$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
  "changelog": [
    "@changesets/changelog-github",
    { "repo": "ORGNAME/Core" }
  ],
  "commit": true,
  "fixed": [],
  "linked": [],
  "access": "restricted",
  "baseBranch": "master",
  "updateInternalDependencies": "patch",
  "ignore": [],
  "privatePackages": { "version": true, "tag": true }
}

When running the job I'm getting the following erorr:

/opt/hostedtoolcache/node/16.18.1/x64/bin/node /home/runner/work/Core/Core/node_modules/@changesets/cli/bin.js version
🦋  error Error: Cannot find module '@changesets/changelog-github'
🦋  error Require stack:
🦋  error - /home/runner/work/Core/Core/.changeset/noop.js
🦋  error     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
🦋  error     at resolveFileName (/home/runner/work/Core/Core/node_modules/resolve-from/index.js:29:39)
🦋  error     at resolveFrom (/home/runner/work/Core/Core/node_modules/resolve-from/index.js:43:9)
🦋  error     at Object.module.exports [as default] (/home/runner/work/Core/Core/node_modules/resolve-from/index.js:46:47)
🦋  error     at getNewChangelogEntry (/home/runner/work/Core/Core/node_modules/@changesets/apply-release-plan/dist/apply-release-plan.cjs.dev.js:391:54)
🦋  error     at Object.applyReleasePlan [as default] (/home/runner/work/Core/Core/node_modules/@changesets/apply-release-plan/dist/apply-release-plan.cjs.dev.js:301:37)
🦋  error     at version (/home/runner/work/Core/Core/node_modules/@changesets/cli/dist/cli.cjs.dev.js:642:69)
🦋  error     at async run$2 (/home/runner/work/Core/Core/node_modules/@changesets/cli/dist/cli.cjs.dev.js:1425:11) {
🦋  error   code: 'MODULE_NOT_FOUND',
🦋  error   requireStack: [ '/home/runner/work/Core/Core/.changeset/noop.js' ]
🦋  error }
Error: The process '/opt/hostedtoolcache/node/16.[18](https://github.com/ORGNAME/Core/actions/runs/3620528095/jobs/6102854308#step:5:19).1/x64/bin/node' failed with exit code 1
    at m._setResult (/home/runner/work/_actions/changesets/action/v1/dist/index.js:136:7258)
    at m.CheckComplete (/home/runner/work/_actions/changesets/action/v1/dist/index.js:136:6686)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/changesets/action/v1/dist/index.js:136:57[23](https://github.com/ORGNAME/Core/actions/runs/3620528095/jobs/6102854308#step:5:24))
Error: The process '/opt/hostedtoolcache/node/16.18.1/x64/bin/node' failed with exit code 1
    at ChildProcess.emit (node:events:390:[28](https://github.com/ORGNAME/Core/actions/runs/3620528095/jobs/6102854308#step:5:29))
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:[30](https://github.com/ORGNAME/Core/actions/runs/3620528095/jobs/6102854308#step:5:31)1:5)
@Andarist
Copy link
Member

Andarist commented Dec 5, 2022

Did you add @changesets/changelog-github to your dependencies?

@maximveksler
Copy link
Author

@Andarist i'm using pnpm as my package manager. Running with the plain changeset rules it's working as expected.

Please see as following

Would you suggest I update .github/workflows/release.yml to add yarn add @changesets/changelog-github ?

@Andarist
Copy link
Member

Andarist commented Dec 5, 2022

Would you suggest I update .github/workflows/release.yml to add yarn add @changesets/changelog-github ?

I was suggesting that it should just get simply installed in your project. I don't see a huge value in installing it only on CI - just add it to your root package.json

@allbetter-max
Copy link
Contributor

allbetter-max commented Dec 5, 2022

@Andarist Thank you!

I was misundersting the way the action works, as I'm using a monorepo pnpm based structure while the documenation (by default) provides a yarn based example.

I've add to my pnpm the dependency

pnpm add -Dw @changesets/changelog-github

And updated my action file to

name: Release

on:
  push:
    branches:
      - master

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: pnpm/action-setup@v2
        with:
          version: 7

      - name: Install Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: "pnpm"

      - run: pnpm install --aggregate-output --reporter append-only --frozen-lockfile

      - name: Create Release Pull Request
        uses: changesets/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

(n.b. also deleted the yarn.lock files that mysteriously generated in my repo :)

Now everything works great and as expected

The action item I would assume it to update the documentation for people who are using pnpm or npm managers.

Other than that this Issue can be closed.

@Andarist
Copy link
Member

Andarist commented Dec 5, 2022

I don't think this is specific to the package manager and I'm not sure how our docs could be improved. However, I'm just skimming this issue - if you have any ideas on how the docs could be improved... we always accept PRs :)

@Andarist Andarist closed this as completed Dec 5, 2022
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

3 participants