In my Angular 6 project, I am using TypeScript version "2.7.2" and the tsconfig.json
file looks like this:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
},
"paths":{
"@services/*": ["app/services/*"]
}
}
I attempted to import a service using the path provided above:
import { AppService } from '@services/app.service';
However, when I run ng serve
, I encounter the following error:
ERROR in src/app/app.module.ts(20,26): error TS2307: Cannot find module '@services/app.service'.
P.S.- Importing the service without the configured path like this:
import { AppService } from './services/app.service';
works perfectly fine.