How to bring in a module from another package in Angular 4

This is a fundamental query.

As an individual just starting with Angular and npm, this may seem like a basic question for some. However, despite extensive research, I haven't been able to find a solution.

Before embarking on a project, I want to create a small proof of concept. I aim to utilize a package named Imported within another package called Importer

The package.json file of Importer lists Imported as a dependency:

"dependencies": {
    ...
    "imported": "file:../Imported",
    ...
}

As expected, Imported can be found in the node_modules folder of Importer.

I have followed Angular's guidelines on reusing modules. The sample they provide is exactly what I am attempting, albeit from within a dependency.

Consequently, I imported ImportedAppModule in Importer's app.module.ts.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';


import { AppComponent } from './app.component';
import { ImportedAppModule } from 'imported/src/app/app.module';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule, 
    ImportedAppModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

In addition, I exported the component in Imported's app.module.ts :

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';


import { ImportedAppComponent } from './app.component';


@NgModule({
  declarations: [
    ImportedAppComponent
  ],
  imports: [
    BrowserModule
  ],
  exports: [
    ImportedAppComponent
  ],
  providers: [],
  bootstrap: [ImportedAppComponent]
})
export class ImportedAppModule { }

Despite this setup, I encountered the following error:

ERROR in ../imported/src/app/app.module.ts Module build failed: Error: \imported\src\app\app.module.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

It appeared that I needed to include this dependency in tsconfig.app.json. However, I also came across information suggesting otherwise and that it should be included in the Importer's bootstrap array. I tried both approaches, but neither proved successful. Nevertheless, the specific configuration details are not covered in this query.

So, here's my dilemma - What's the standard procedure for handling this situation? Am I moving in the right direction? If so, what should be my next step?

I attempted using ng build --aot in the Imported package and added the dependency to the dist folder in Importer initially. Unfortunately, it resulted in a failure stating the absence of a package.json file. Subsequently, I considered resorting to jit methodology; however, my preference remains leaning towards aot.

Your advice and guidance will be greatly appreciated. Thank you in advance!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide for bringing in a complete npm library into React Native beyond just a single file access

Currently, I am facing an issue with importing the sjcl library into my project. Even though there are multiple files within the library, I am only able to import one file successfully. This is what I have tried from the command line: npm install sjcl -- ...

"Error message: Trying to import a component in Angular, but encountering a message stating that the component has no exported

When creating a component named headerComponent and importing it into app.component.ts, an error is encountered stating that 'website/src/app/header/app.headerComponent' has no exported member 'headerComponent'. The code for app.headerC ...

Module for migration located in a subdirectory

Currently, I am in the process of transitioning an Angular application to NativeScript while utilizing a code-sharing setup. For the migration of Angular modules, I have been executing the following command: ng g migrate-module --name=nameModule However ...

"String representation" compared to the method toString()

Currently, I am in the process of writing unit tests using jasmine. During this process, I encountered an issue with the following code snippet: let arg0: string = http.put.calls.argsFor(0) as string; if(arg0.search(...) This resulted in an error stating ...

The angular application is experiencing issues with the injection not functioning correctly

In my MVC application, I have an Angular application that I want to extract and turn into a standalone application. I created a new minimal version of the Angular application using CLI, copied over the package.json file, installed all necessary packages, ...

Establishing default query parameters during the routing process

Here is the current route configuration I am working with: const routes: Routes = [ // other routes { component: UsersListComponent, path: 'users' } ]; I am looking to automatically add default QUERY parameters whenever a route goes to this ...

Prevent automatic submission of forms when selecting attributes in HTML forms using AngularJS

I need to create a form where users can select their branch of study. Here is the form I have designed- <form method="post" [formGroup]="formData" (click)="dataSubmit()" > <div class="form-group"> <label for="branch">Selec ...

What is the method for retrieving the index of an enum member in Typescript, rather than the member name?

Here is an example of how to work with enums in TypeScript: export enum Category { Action = 1, Option = 2, RealEstateFund = 3, FuturesContract = 4, ETFs = 5, BDRs = 6 } The following function can be used to retrieve the enum indexe ...

When installing node.js, npm does not automatically get installed as well

When I was hosting my webapp on Heroku, I encountered an error regarding bugs in my npm package. My npm package was version 3 while my node.js was version 8. Thinking that updating the npm version would solve the issue, I tried to update it but was unsuc ...

Converting the information retrieved from Firebase into a different format

My Project: In my Angular SPA, I am trying to retrieve data from Firebase and display specific values on the screen. Approach Taken: The data returned from Firebase looks like this: Returned Data from Firebase Error Encountered: In order to display the ...

Exploring NPM: Utilizing the Groan Module and Uncovering the PHP Session File Name Location

I am trying to figure out how to access PHP session data in Node.js After conducting some research, I came across a helpful thread on Stack Overflow titled "Read PHP Session data in node.js" Following the advice from the thread, I used a sample code prov ...

Error message stating: rxjs and firebase encountered a TypeError when attempting to add property 0 because the object is not

My angular application interacts with firebase firestore as the backend database. I am working on a function to retrieve document snapshots from firestore in a generic way. Here is the code snippet where I encounter an error: /** * Get a 'liste ...

Missing 'Include in Project' option for ASP.Net Core project

After setting up my Asp.Net Core project in VS 2015 Update 3 and installing 'twitter bootstrap' through npm, I encountered an issue when trying to include the "bootstrap" folder into my project. The "Include in project" option was not showing up ...

The issue with Rxjs forkJoin not being triggered within an Angular Route Guard

I developed a user permission service that retrieves permissions from the server for a specific user. Additionally, I constructed a route guard that utilizes this service to validate whether the user possesses all the permissions specified in the route. To ...

Change a Typescript class into a string representation, utilizing getter and setter methods in place of private variables

Below is a snippet of TypeScript code: class Example { private _id: number; private _name: string; constructor(id: number, name: string) { this._id = id; this._name = name; } public get id(): number { return t ...

Issue in Vue/Node application: Rule is restricted to a single resource source

I just recently started diving into Vue and Node, and things were going smoothly with a Vue3 project I was experimenting with to enhance my skills. I decided to incorporate scss files, so I went ahead and installed sass-loader via npm using: npm install sa ...

Problem with Angular Slider

I'm in the process of creating a carousel component in Angular, but I'm facing an issue where the carousel is not appearing as it should. Below is the code for my carousel component. carousel.component.html: <div class="carousel"> ...

during the process of installing expo cli

E:>npm i -g expo-cli npm WARN deprecated [email protected]: Further details can be found at: https://github.com/lydell/source-map-url#deprecated npm WARN deprecated [email protected]: View more information here: https://github.com/lydell/urix# ...

Issue with npm resolution due to package requiring another third-party dependency

I'm encountering an issue with a requirement and I'm hoping for some assistance. I currently have a package called @unicoderns/orm that relies on mysql, which can be found at https://github.com/unicoderns/ORM Now I'm working on developing ...

While trying to install express using Node.js, an error (error:0906D06C :PEM routines : PEM_read_bio npm) occurred

I recently installed node.js on my computer and npm came along with it. However, when I try to execute "npm install express" in my Windows command prompt, I encounter the following error message. Can anyone guide me on how to resolve this issue? C:\U ...