using path on tsconfig.json doesn't resolve using angular

Viewed 3222

In order to avoid relative path when I import file, I try to configure angular to understand path.

So far, it's not working at all, my code :

//tsconfig.app.json
"compilerOptions":{
    //lot of things . If it matter moduleResultion is set to node
    "baseUrl": ".",
    "paths": {
        "@modules": ["app/modules/"]
        ...
    },
}



//in a component: 
import { X } from '@modules/Y/component/index'

when running ng serve , the console output an error about : : Cannot find module '@modules/Y/component/index'.

This is definitly working with relative path like import { X } from ../../../modules/Y/component/index

So, I expect my tsconfig.app.json or tsconfig.json ( or maybe both) are wrong, however, I can't find any good tutorial about how to do it correctly for an angular app.

Currently using angular 4 with basic associate tools (typescript 2.3.3, angular-cli 1.0.6 and provide webpack)

Can you point out the problem to me, or give me a good doc/tuto that resolve this issue with angular please ? All the answer I have seen so far on SO or github issue didn't work at all.

NOTE : The architecture looks like this

project
   |
   -tsconfig.json //had try things on this one too but does nothing.
   -src/
     |
     -tsconfig.app.json
     -app/
       |
       -modules
       -othersFolder
1 Answers
Related