#Paths problem

54 messages · Page 1 of 1 (latest)

sick cloud
#

In typescript config i have configs paths:

    "paths": {
      "@/schemas/*" : ["./src/schemas/*"],
      "@/types/*" : ["src/types/*"],
      "@/constants" : ["src/constants"],
      "@/errors/*" : ["src/res/errors/*"],
      "@/success/*" : ["src/res/success/*"],
      "@/functions/*" : ["src/functions/*"],
    }

But return error(See screen)

sick cloud
#

???

sick cloud
#

any help?

wind drift
#

Let me see

#

Do you have "baseUrl" set up?

#

Your "@/schemas/*" has extra ./ in the path mapping

sick cloud
#

yes

wind drift
#

Here are full settings I have in my project that I currently work on

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": ".",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false,
    "paths": {
        "@common/*":    ["src/common/*"],

        "@constant/*":  ["src/common/constant/*"],
        "@dto/*":       ["src/common/dto/*"],
        "@decorator/*": ["src/common/decorator/*"],
        "@guard/*":     ["src/common/guard/*"],
        "@interface/*": ["src/common/interface/*"],
        "@types/*":     ["src/common/types/*"],

        "@constant":    ["src/common/constant/index"],
        "@dto":         ["src/common/dto/index"],
        "@decorator":   ["src/common/decorator/index"],
        "@guard":       ["src/common/guard/index"],
        "@interface":   ["src/common/interface/index"],
        "@types":       ["src/common/types/index"]
    },
  }
}
wind drift
sick cloud
#

ok

#

now i try

#

not work

#
{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": ".",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false,
    "paths": {
      "@/schemas/*" : ["src/schemas/*"],
      "@/types/*" : ["src/types/*"],
      "@/constants" : ["src/constants"],
      "@/errors/*" : ["src/res/errors/*"],
      "@/success/*" : ["src/res/success/*"],
      "@/functions/*" : ["src/functions/*"],
    }
  }
}
#

it is my ts confi

#

config

wind drift
#

Do you have any constant import?
Because your line look like this: "@/constants" : ["src/constants"],

#

Others look in the pattern of: @/folder/*

sick cloud
#

It is builded file

wind drift
#

I.e. your constant is missing a slash and an asterisk

sick cloud
#

only @/success and @/errors has error

wind drift
#

That's really weird

#

Do you have any outdated packages?

sick cloud
#

no

#

@subtle cloud it is nest js bug?

subtle cloud
#

Most likely this is a config problem

sick cloud
#

yes

subtle cloud
sick cloud
#

but only @/sucess and @/error as this error

#

anorther path is ok

sick cloud
subtle cloud
sick cloud
#

in dist folder

#

i have view the build service file

#

and only @/sucess and @/error as not replace path

subtle cloud
#

I get that

#

I understand that problem

sick cloud
subtle cloud
#

Trust me, I do

#

I'm asking for you to be able to provide me with a reproduction so I can see it happen locally and better debug it

#

I'm asking for you to be able to provide me with a reproduction so I can see it happen locally and better debug it

sick cloud
#

You are creating the repository

subtle cloud
#

Why should I create it? You're the one with the bug, the onus is on you to provide the reproduction

sick cloud
#

No

#

Sorry I'm creating reposotory

subtle cloud
#

Couldn't have made something public?

sick cloud
#

?

subtle cloud
#

Your code errors out because the accountError and accountSuccess are d.ts files, or type files, so they don't get transpiled to .js files. Due to this, when Nest ends up calling tsconfig-paths under the hood and converting the path mappings, it doesn't find any dist/src/res/accountSuccess.js file so it doesn't know that path can be omitted

subtle cloud
# sick cloud ?

A minimum reproduction should be publicly available so anyone can help and learn from it, not just the maintainer who is debugging the issue. This allows for more eyes, more minds, and more learning experiences. https://minimum-reproduction.wtf

sick cloud
#

Ok for fix it?

subtle cloud
#

Change these files from d.ts to .ts

#

You should almost never be writing d.ts files. Those are type files for Typescript and are omitted by the runtime