Skip to content
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

Paths not being transformed #237

Open
aryzing opened this issue Jan 29, 2023 · 2 comments
Open

Paths not being transformed #237

aryzing opened this issue Jan 29, 2023 · 2 comments

Comments

@aryzing
Copy link

aryzing commented Jan 29, 2023

After setting up a barebones project, with a minimal tsconfig, the the aliased paths are not properly converted when running the app with ts-node. This is the exact config being used,

{
  "include": ["src"],

  "compilerOptions": {
    // Type Checking
    "strict": true,

    // Modules
    "baseUrl": ".",
    "module": "ESNext",
    "moduleResolution": "node",
    "paths": {
      "@foo/*": ["src/foo/*"]
    },

    // Emit
    "noEmit": true,

    // Interop Constraints
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,

    // Language and Environment
    "jsx": "react-jsx",
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "target": "ESNext",

    // Completeness
    "skipLibCheck": true
  },
  "ts-node": {
    "esm": true,
    "experimentalSpecifierResolution": "node",
    "require": ["tsconfig-paths/register"]
  }
}

The error is,

$ pnpm ts-node src/index.ts 
/path/node_modules/.pnpm/ts-node@10.9.1_awa2wsr5thmg3i7jqycphctjfq/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:757
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base));
        ^
CustomError: Cannot find package '@foo/bar' imported from /path/src/index.ts

The file structure is as follows,

├── node_modules
│   ├── tsconfig-paths -> .pnpm/tsconfig-paths@4.1.2/node_modules/tsconfig-paths
│   ├── ts-node -> .pnpm/ts-node@10.9.1_awa2wsr5thmg3i7jqycphctjfq/node_modules/ts-node
│   ├── ts-unused-exports -> .pnpm/ts-unused-exports@9.0.2_typescript@4.9.4/node_modules/ts-unused-exports
│   ├── @types
│   │   └── node -> ../.pnpm/@types+node@18.11.18/node_modules/@types/node
│   └── typescript -> .pnpm/typescript@4.9.4/node_modules/typescript
├── package.json
├── pnpm-lock.yaml
├── README.md
├── src
│   ├── foo
│   │   └── bar.ts
│   └── index.ts
└── tsconfig.json
@jnxey
Copy link

jnxey commented Feb 10, 2023

@aryzing Is the problem solved? I also encountered the same problem

@jnxey
Copy link

jnxey commented Feb 10, 2023

I found the answer here: TypeStrong/ts-node#1450 (comment)

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

No branches or pull requests

2 participants