Content-Length: 234627 | pFad | http://github.com/tapjs/tapjs/issues/1049

C0 "Cannot find module or its corresponding type declarations" with typescript >=5.6 · Issue #1049 · tapjs/tapjs · GitHub
Skip to content

"Cannot find module or its corresponding type declarations" with typescript >=5.6 #1049

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

Open
3 tasks done
lukekarrys opened this issue Feb 8, 2025 · 0 comments
Open
3 tasks done
Labels
bug something not go good

Comments

@lukekarrys
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Have you read the CONTRIBUTING guide on posting bugs, and CODE_OF_CONDUCT?

  • yes I read the things

This issue exists in the latest tap version

  • I am using the latest tap

Description

I noticed this behavior in tap when using the built-in @tapjs/typescript plugin, but I was able to follow it down to @isaacs/ts-node-temp-fork-for-pr-2009. So I don't think this is a bug in tap but didn't know where else to report it. The upstream ts-node doesn't work in other ways so I was not able to test with that.

When trying to run tap on a workspace where its test files import from another workspace, @isaacs/ts-node-temp-fork-for-pr-2009 is unable to find the workspace. Running tsc directly on the workspace's test files does work.

Reproduction

run.sh

#!/usr/bin/env bash

set -eo pipefail

# Reset
rm -rf node_modules/ package-lock.json

# Root
cat <<EOF > tsconfig.json
{
  "compilerOptions": {
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "target": "es2022"
  }
}
EOF
cat <<EOF > package.json
{
  "name": "@lukekarrys/root",
  "version": "1.0.0",
  "private": true,
  "workspaces": [
    "pkg-a",
    "pkg-b"
  ],
  "dependencies": {
    "@isaacs/ts-node-temp-fork-for-pr-2009": "^10.9.7",
    "typescript": "$1"
  }
}
EOF

# Pkg A
DIR="pkg-a"
mkdir -p $DIR
cat <<EOF > $DIR/package.json
{
  "name": "@lukekarrys/pkg-a",
  "version": "1.0.0",
  "type": "module",
  "exports": {
    ".": {
      "import": {
        "types": "./index.d.ts",
        "default": "./index.js"
      }
    }
  }
}
EOF
cat <<EOF > $DIR/tsconfig.json
{
  "extends": "../tsconfig.json"
}
EOF
cat <<EOF > $DIR/index.d.ts
export declare const a = "a";
EOF
cat <<EOF > $DIR/index.js
export const a = 'a';
EOF

# Pkg A
DIR="pkg-b"
mkdir -p $DIR
cat <<EOF > $DIR/package.json
{
  "name": "@lukekarrys/pkg-b",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "@lukekarrys/pkg-a": "1.0.0"
  }
}
EOF
cat <<EOF > $DIR/tsconfig.json
{
  "extends": "../tsconfig.json"
}
EOF
cat <<EOF > $DIR/index.ts
import { a } from '@lukekarrys/pkg-a'
console.log(a)
EOF

# Run
set -x

npm i
npm ls typescript
./node_modules/.bin/tsc --version
./node_modules/.bin/tsc --project pkg-b/tsconfig.json --noEmit
node --import=./node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs ./pkg-b/index.ts

When running that script with typescript@5.5 vs 5.6, tsc is able to compile but @isaacs/ts-node-temp-fork-for-pr-2009 is not. Here's the output on my system:

./run.sh 5.5

+ npm i

added 20 packages, and audited 23 packages in 827ms

found 0 vulnerabilities
+ npm ls typescript
@lukekarrys/root@1.0.0 /Users/lukekarrys/Desktop/isaacs-tsnode-tap-error
├─┬ @isaacs/ts-node-temp-fork-for-pr-2009@10.9.7
│ └── typescript@5.5.4 deduped
└── typescript@5.5.4

+ ./node_modules/.bin/tsc --version
Version 5.5.4
+ ./node_modules/.bin/tsc --project pkg-b/tsconfig.json --noEmit
+ node --import=./node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs ./pkg-b/index.ts
a

./run.sh 5.6

+ npm i

added 20 packages, and audited 23 packages in 906ms

found 0 vulnerabilities
+ npm ls typescript
@lukekarrys/root@1.0.0 /Users/lukekarrys/Desktop/isaacs-tsnode-tap-error
├─┬ @isaacs/ts-node-temp-fork-for-pr-2009@10.9.7
│ └── typescript@5.6.3 deduped
└── typescript@5.6.3

+ ./node_modules/.bin/tsc --version
Version 5.6.3
+ ./node_modules/.bin/tsc --project pkg-b/tsconfig.json --noEmit
+ node --import=./node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs ./pkg-b/index.ts

node:internal/modules/run_main:122
    triggerUncaughtException(
    ^
Error: ⨯ Unable to compile TypeScript:
pkg-b/index.ts(1,19): error TS2307: Cannot find module '@lukekarrys/pkg-a' or its corresponding type declarations.
    at async nextLoad (node:internal/modules/esm/hooks:748:22)
    at async Hooks.load (node:internal/modules/esm/hooks:385:20)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:199:18) {
  diagnosticCodes: [ 2307 ]
}

Node.js v22.13.0

Environment

╰❯ npm ls @isaacs/ts-node-temp-fork-for-pr-2009
@lukekarrys/root@1.0.0
└── @isaacs/ts-node-temp-fork-for-pr-2009@10.9.7

╰❯ uname -a
Darwin pieholden.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030 arm64 arm Darwin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something not go good
Projects
None yet
Development

No branches or pull requests

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tapjs/tapjs/issues/1049

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy