Skip to content

fix: typescript is now required as of 17.7.1 but is not in the dependency list #3665

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

Closed
1 of 4 tasks
binomialstew opened this issue Sep 14, 2023 · 6 comments
Closed
1 of 4 tasks
Labels

Comments

@binomialstew
Copy link

Expected Behavior

I should be able to lint commits without a need for typescript.

Current Behavior

Fatal error when running commitlint:

Error: Cannot find module 'typescript'

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

@commitlint/[email protected] did not present this issue.

Steps to Reproduce

1. Install commitlint v17.7.1 in a project without typescript
2. Try to lint a commit

Context

No response

commitlint --version

@commitlint/[email protected]

git --version

v2.32.0

node --version

v18.17.1

@escapedcat

This comment was marked as outdated.

@binomialstew

This comment was marked as outdated.

@escapedcat

This comment was marked as outdated.

@binomialstew
Copy link
Author

This has come up again.

Repro example:
https://github.com/binomialstew/commitlint-repro

I’ve narrowed it down to happen when the commitlint dependencies are listed in a subpackage of a monorepo. When these dependencies are defined in the top level package.json, there is no issue. I have noticed that the dependency tree for typescript is different between these cases. For example, when commitlint and @commitlint/config-conventional are required by the subpackage:

npm why typescript


typescript@"^4.6.4 || ^5.0.0" from @commitlint/[email protected]
  node_modules/@commitlint/load
    @commitlint/load@"^17.7.1" from @commitlint/[email protected]
    node_modules/@commitlint/cli
      @commitlint/cli@"^17.7.1" from [email protected]
      node_modules/commitlint
        dev commitlint@"^17.7.1" from repro-subpackage@undefined
        packages/repro-subpackage
          repro-subpackage@undefined
          node_modules/repro-subpackage
            workspace packages/repro-subpackage from the root project

and when they are only in the root package:

npm why typescript


[email protected] dev
node_modules/typescript
  peer typescript@">=3" from [email protected]
  node_modules/cosmiconfig-typescript-loader
    cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/[email protected]
    node_modules/@commitlint/load
      @commitlint/load@"^17.7.1" from @commitlint/[email protected]
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.7.1" from [email protected]
        node_modules/commitlint
          dev commitlint@"^17.7.1" from repro-subpackage@undefined
          packages/repro-subpackage
            repro-subpackage@undefined
            node_modules/repro-subpackage
              workspace packages/repro-subpackage from the root project
  peer typescript@">=2.7" from [email protected]
  node_modules/ts-node
    peer ts-node@">=10" from [email protected]
    node_modules/cosmiconfig-typescript-loader
      cosmiconfig-typescript-loader@"^4.0.0" from @commitlint/[email protected]
      node_modules/@commitlint/load
        @commitlint/load@"^17.7.1" from @commitlint/[email protected]
        node_modules/@commitlint/cli
          @commitlint/cli@"^17.7.1" from [email protected]
          node_modules/commitlint
            dev commitlint@"^17.7.1" from repro-subpackage@undefined
            packages/repro-subpackage
              repro-subpackage@undefined
              node_modules/repro-subpackage
                workspace packages/repro-subpackage from the root project
    ts-node@"^10.8.1" from @commitlint/[email protected]
    node_modules/@commitlint/load
      @commitlint/load@"^17.7.1" from @commitlint/[email protected]
      node_modules/@commitlint/cli
        @commitlint/cli@"^17.7.1" from [email protected]
        node_modules/commitlint
          dev commitlint@"^17.7.1" from repro-subpackage@undefined
          packages/repro-subpackage
            repro-subpackage@undefined
            node_modules/repro-subpackage
              workspace packages/repro-subpackage from the root project
  typescript@"^4.6.4 || ^5.0.0" from @commitlint/[email protected]
  node_modules/@commitlint/load
    @commitlint/load@"^17.7.1" from @commitlint/[email protected]
    node_modules/@commitlint/cli
      @commitlint/cli@"^17.7.1" from [email protected]
      node_modules/commitlint
        dev commitlint@"^17.7.1" from repro-subpackage@undefined
        packages/repro-subpackage
          repro-subpackage@undefined
          node_modules/repro-subpackage
            workspace packages/repro-subpackage from the root project

You can try running npm run commitlint in the main branch of the repro example I’ve shared. It should fail with Error: Cannot find module 'typescript’. The in-root branch moves the 2 commitlint dependencies to the top level, removes them from the packages/repro-subpackage and updates the lock. Running npm run commitlint there should work without issue.

@binomialstew binomialstew reopened this Sep 15, 2023
@joberstein
Copy link
Contributor

@binomialstew I downloaded your repo and it seems like this is resolved with @commitlint/load v18.2.0 - #3722 . Can you double-check if that's the case?

@binomialstew
Copy link
Author

@binomialstew I downloaded your repo and it seems like this is resolved with @commitlint/load v18.2.0 - #3722 . Can you double-check if that's the case?

Confirmed I am not seeing that error with v18.2.0. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants