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

ts-node/esm - cannot use path from tsconfig.json #1728

Closed
testgitdl opened this issue Apr 21, 2022 · 2 comments
Closed

ts-node/esm - cannot use path from tsconfig.json #1728

testgitdl opened this issue Apr 21, 2022 · 2 comments

Comments

@testgitdl
Copy link

Expected Behavior

I have a playwright + cucumber project where I'm importing PO's and I want to use tsconfig-paths defined in my tsconfig.json but these do not seem to work.
Here is the project: https://github.com/testgitdl/cucumber-playwright-ang13

Actual Behavior

In login.page.ts: works -> import { page } from '../support/hooks.js';
doesn't work -> import { page } from '@support';

Steps to reproduce the problem

Here is the project: https://github.com/testgitdl/cucumber-playwright-ang13

My login.page.ts looks like this:
import { expect } from "chai";
// import { page } from '@support';
import { page } from '../support/hooks.js';

export class LoginPage {

async navigate() {
await page.goto('https://playwright.dev/');
}

async test() {
console.log('okkkk');
}
}

My tsconfig.json looks like this:
{
"compileOnSave": false,
"compilerOptions": {
"downlevelIteration": true,
"importHelpers": true,
"module": "es2020",
"outDir": "./dist/out-tsc",
"baseUrl": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"target": "es2020",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2020",
"dom"
],
"paths": {
"@support": [
"./e2e/support/"
],
"@support/
": [
"./e2e/support/*"
]
}
}
}

To run the tests: npm run test

Minimal reproduction

Specifications

  • ts-node version:
  • node version:
  • TypeScript version:
  • tsconfig.json, if you're using one:
{}
  • Operating system and version:
  • If Windows, are you using WSL or WSL2?:
@cspotcode
Copy link
Collaborator

Looks like a duplicate of #1375?

See also: #1596 (comment)

@testgitdl
Copy link
Author

Indeed, it is a duplicate

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