8000 Can't make paths work properly · Issue #19453 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Can't make paths work properly #19453
Closed
Closed
@BUONJG

Description

@BUONJG

Hello,

I'm trying to use paths property in my tsconfig.json file.

It makes the build work perfectly but execution of generated js is failing.

My tsconfig.json:

{
    "compileOnSave": false,
    "compilerOptions": {
        "outDir": "./dist",
        "baseUrl": "./src",
        "paths": {
            "core/*": [
                "core/*"
            ]
        },
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
            "node_modules/@types"
        ]
    },
    "include": [
        "src/**/*"
    ]
}

src/core/service.ts:

export class Service {
    public static log(message: string) {
        console.log('message', message);
    }
}

src/core/index.ts:

export * from './service';

src/index.ts:

import { Service } from 'core';
Service.log('test');

The build is working perfectly

But running dist\index.js I obtain:

Error: Cannot find module 'core'

Am I doing something wrong?

I made a repo to illustrate this:
https://github.com/BUONJG/typescript-paths.git

Many thanks for your support,

Jean-Guy

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0