Can't find module @changesets/cli/changelog when installed globally
See original GitHub issueAffected Packages
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:
- Created a year ago
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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" }
The funny thing is that solution also doesn’t work.
Setting
"changelog": "@changesets/changelog-git"
in.changeset/config.json
and then runningnpm 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.