Skip to content

Import error when using package alias instead of relative path #8

@alessbarb

Description

@alessbarb

I'm facing an import issue with the @labrynx/error-enhanced package in a TypeScript project. Specifically, the following import statement does not work:

import { ... } from "@labrynx/error-enhanced";

However, using the relative path does work:

import { ... } from "../node_modules/@labrynx/error-enhanced/dist";

Steps to Reproduce:

  1. Install the @labrynx/error-enhanced package.
  2. Try to import it using import { ... } from "@labrynx/error-enhanced";
  3. Observe that the import fails.

Expected Behavior:

The package should be imported successfully using the package alias.

Actual Behavior:

The import fails unless a relative path is used.

Environment:

  • Node.js version: >=16.0.0
  • npm version: >=8.0.0
  • TypeScript version: 5.2.2

Additional Information:

Here is the package.json configuration related to error-enhanced:

{
  "main": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "exports": [
    "./dist/index.js"
  ]
}

And here is the tsconfig.json:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "rootDir": "src",
    "outDir": "dist/",
    ...
  }
}

Any help on this would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions