As I was going through the themes, I couldn't find a similar question. My issue revolves around Angular's inability to locate modules and services that are created using "ng g". Everything seems to be correctly set up, but errors or warnings keep popping up.
The service itself contains multiple methods (functions):
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class NameServices{...}
How should I import this service into a component:
import {NameServices} from '../../@core/utils/NameServices.service';
The problems encountered in the console are as follows:
▲ [WARNING] Import "NameServices" will always be undefined because the file "src/app/@core/utils/NameServices.service.ts" has no exports [import-is-undefined]
src/app/pages/home/home.component.ts:5:9:
5 │ import {NameServices} from '../../@core/utils/NameServi...
╵ ~~~~~~~~~~~~~~~~~~~~~~~
X [ERROR] TS1490: File appears to be binary. [plugin angular-compiler]
src/app/@core/utils/NameServices.service.ts:0:0:
0 │
╵ ^
X [ERROR] TS2306: File '*:/Projects/client/src/app/@core/utils/NameServices.service.ts' is not a module. [plugin angular-compiler]
src/app/pages/home/home.component.ts:7:38:
7 │ ...rvices} from '../../@core/utils/NameServices.service';
I have attempted various fixes including manual path configurations in tsconfig, changing module versions, etc., which usually lead to more complications.
Is it necessary to adjust dependencies in App.module.ts?
(It appears to be functional, but these console logs are frustrating.)
PS: tsconfig.json
{
"compileOnSave": false,
"include": ["./src/app/@core/**/*"],
"compilerOptions": {
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"useDefineForClassFields": false,
"lib": [
"ES2022",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}