question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't find module @changesets/cli/changelog when installed globally

See original GitHub issue

Affected Packages

@changesets/cli

Problem

I’m currently trying to use @changesets/cli within a pipeline without needing to install global dependencies to use changelogs. As such I have @changesets/cli globally installed on the pipeline runner, using npx to run the command.

When using npx changeset everything works fine, but using npx changeset version throws the following error:

$ npx changeset version
🦋  error Error: Cannot find module '@changesets/cli/changelog'
🦋  error Require stack:
🦋  error - /myuser/myproject/.changeset/noop.js
🦋  error     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
🦋  error     at resolveFileName (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/node_modules/resolve-from/index.js:29:39)
🦋  error     at resolveFrom (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/node_modules/resolve-from/index.js:43:9)
🦋  error     at Object.module.exports [as default] (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/node_modules/resolve-from/index.js:46:47)
🦋  error     at getNewChangelogEntry (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/node_modules/@changesets/apply-release-plan/dist/apply-release-plan.cjs.dev.js:391:54)
🦋  error     at Object.applyReleasePlan [as default] (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/node_modules/@changesets/apply-release-plan/dist/apply-release-plan.cjs.dev.js:301:37)
🦋  error     at version (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/dist/cli.cjs.dev.js:625:69)
🦋  error     at async run$2 (/myuser/.nvm/versions/node/v16.17.0/lib/node_modules/@changesets/cli/dist/cli.cjs.dev.js:1367:11) {
🦋  error   code: 'MODULE_NOT_FOUND',
🦋  error   requireStack: [
🦋  error     '/myuser/myproject/.changeset/noop.js'
🦋  error   ]
🦋  error }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I have looked into my global install of changesets and while changelog is a subdirectory within the package itself, it does not get installed into the packages node_modules, which is how I would explain why it can’t actually find the module.

Minimal reproduction

Navigate into the repository using changesets.

rm -rf node_modules npm i -g @changesets/cli npx changeset version

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
greatyehanlicommented, Oct 2, 2022

Just found the workaround. I found that the changelog path configuration in config json is relative to the directory path of .changeset. If you want to refer to the actual code to see the instant result as you are coding, just give a relative path like { "changelog": "../{rootPathOfMonorepo}/changesets/packages/cli/changelog" }

1reaction
chris-ldgkcommented, Sep 15, 2022

The funny thing is that solution also doesn’t work.

Setting "changelog": "@changesets/changelog-git" in .changeset/config.json and then running npm i -g @changesets/cli @changesets/changelog-git && npx changeset version still throws the same error.

Though I’m inclined to think there’s a quirk about how globally installed npm packages work that I don’t know that’s causing this, rather than a problem with changesets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module when installed globally #10422 - GitHub
Some modules cannot be found when installed globally. Say I have: C:\Users\me\AppData\Roaming\npm ├── casperjs@1.1.0-beta3 ...
Read more >
@changesets/cli - npm
Helps you manage the versioning and changelog entries for your packages, with a focus on versioning within a mono-repository (though we support ...
Read more >
Could not find module ember-validations - Stack Overflow
Trying to use ember-validations plugin for ember-cli. Bumped with this issue that I can't figure what is missing. Here is the dependencies part...
Read more >
pnpm/pnpm - Gitter
I'm now setting up a gatsby.js project with pnpm, but pnpm does not install several packages those npm and yarn install, then gatsby...
Read more >
describe-change-set — AWS CLI 1.27.37 Command Reference
For usage examples, see Pagination in the AWS Command Line Interface User Guide . --generate-cli-skeleton (string) Prints a JSON skeleton to standard output ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found