postcss-loader: Cannot find module 'ts-node' (yarn)

Bug report

Actual Behavior

Attempts to build using this loader result in the following:

! Module build failed: Error: Cannot find module 'ts-node'
ERR! Require stack:
ERR! - /home/circleci/project/node_modules/cosmiconfig-typescript-loader/dist/cjs/index.js

Expected Behavior

https://github.com/Codex-/cosmiconfig-typescript-loader/blob/main/package.json#LL39C6-L39C13

cosmiconfig-typescript-loader has a peerDep of ts-node. This module has cosmiconfig-typescript-loader as a dependency - therefore it should specify ts-node as a dependency as well.

How Do We Reproduce?

https://github.com/ntucker/anansi/pull/1941

https://app.circleci.com/pipelines/github/ntucker/anansi/9024/workflows/561c1fc3-70c1-403c-a033-8175c9788786/jobs/47985

Please paste the results of npx webpack info here, and mention other relevant information

  System:
    OS: Linux 5.15 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (20) x64 AMD Ryzen 9 7950X 16-Core Processor
    Memory: 27.62 GB / 31.21 GB
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    Yarn: 3.5.0 - ~/.yarn/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Monorepos:
    Yarn Workspaces: 3.5.0
  Packages:
    babel-loader: 9.1.2 => 9.1.2 
    webpack: 5.77.0 => 5.77.0 
    webpack-cli: 5.0.1 => 5.0.1 
    webpack-dev-server: 4.13.2 => 4.13.2 

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 34 (29 by maintainers)

Most upvoted comments

This still breaks for us. I think because cosmiconfig-typescript-loader is imported without check for ts-node here, which imports ts-node here. So probably the import of cosmiconfig-typescript-loader should become a dynamic import in this block right? wdyt @ntucker?

Getting hit by the same issue here.

Why npm projects keep breaking without any changes even if we set versions in stone? Everytime it’s the same thing! We all are busy with other fish to fry, we cannot bother with this now.

It’s like if you have to go to an appointment with your car and suddenly you’re car is not working. Now you have to debug and update the car. NO, I need the car now…

Sorry for ranting but this is super frustrating…

What we need is a github action that let’s library authors verify compatibility easily so random libraries don’t accidentally violate these things. Even without those tools not specifying this properly leads to ambiguous resolution, which can lead to incredibly difficult to track down issues. It would have been better if these rules were in place at the inception but that’s a lot of ask of new tools

And I said it above that it doesn’t help, but for some reason no one listened to me

@ntucker They list typescript as a peer dependency because ts-node lists it as a peer dependency here: https://github.com/TypeStrong/ts-node/blob/main/package.json#L145

Doesn’t matter if you use ts-node or typescript in this package, you need to either list it as dependency here to fulfill the peer dependency requirements, or list them as peer dependencies to let other packages up the dependency tree fulfill the requirements.

Yes, that’s why I included it in my PR https://github.com/webpack-contrib/postcss-loader/pull/639/files. You should be telling @alexander-akait this since he was the one asking about why typescript was needed.