I've been dealing with a local package that contains a json
file, and my current challenge is to load this json file into the Angular 15 app.component.ts
.
To bring the json file package into my Angular project, I followed this installation process:
npm i @fireflysemantics/fs-a-md
This means that the json file is now accessible within the node_modules
of my Angular project.
The package specifies the main
content in its package.json
file like so:
{
...
"main": "target/content.json"
...
}
In previous versions of Angular, I used to load it in this manner:
import * as data from '@fireflysemantics/fs-a-md';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
content: any = (<any>data).default
}
However, when attempting to do the same in Angular 15, I encountered the following error message:
Error: src/app/app.component.ts:2:23 - error TS2307: Cannot find module '@fireflysemantics/fs-a-md' or its corresponding type declarations.
2 import * as data from '@fireflysemantics/fs-a-md';
Any suggestions on how to resolve this issue?
To confirm that the package is indeed installed, I ran the following ls command:
oleersoy@Oles-MacBook-Pro al % ls node_modules/@fireflysemantics/fs-a-md/target
CNAME robots.txt
app.component.ts route_data.ts
content.json scully.fs-a-app.config.ts
deploy.js sitemap.xml
index.html
oleersoy@Oles-MacBook-Pro al %
As you can see, the file is present...