Can projects be published on npm and installed from a specific directory?

Currently working on an Angular library project, I am exploring the possibility of publishing the entire library alongside a pre-built angular application either on gitlab or npm. However, my concern lies in ensuring that when a user installs the library via npm, only the necessary source files are installed from the /dist directory, without including any unnecessary files (such as the entire application itself).

I am hesitant to have separate repositories, one containing a testing application solely for my use and another with the client-accessible source code.

If anyone has insights or recommendations regarding this issue, please feel free to share!

Warm regards,

Bloodcast69

Answer №1

To specify which files will be published to the registry, you have two options. One is to use the files field in your package.json, where you can list the files you want to include like below for only the dist/ folder:

"files": ["dist"],

The other option is to create a .npmignore file with similar syntax to .gitignore. For example, if you want to exclude the src folder from being published, you can simply add src to the .npmignore file.

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

The error message "Property 'chart' is not available in the - ChartJS - Angular 13" indicates that the specified property '

As a beginner in Angular, I am currently working on my first page using Angular and facing some challenges with implementing onClick functionality in ChartJS Bar graphs. The issue arises when attempting to access this.chart within the onClick event of Cha ...

Transitioning from angular version 5.2 to the latest angular 6.1 version

Currently, I find myself on node 8.11 and utilizing VS code. The project was originally built in version 5.2.5 but has been inactive for some time now. Within my project, the following modules are present: import { BrowserModule } from '@angular/plat ...

What is the process for launching my Angular 8 application on an Apache server running Ubuntu 18?

I am looking for a way to showcase my compiled "dist" folder, which was generated on a Windows system using the command "ng build --prod", on an Ubuntu 18 server that is running Apache. Any suggestions on how I can achieve this? ...

Show a specific form field based on the chosen option in a dropdown menu using Angular and TypeScript

I am looking to dynamically display a form field based on the selected value from a dropdown list. For instance, if 'first' is chosen in the dropdown list, I want the form to remain unchanged. However, if 'two' is selected in the drop ...

What is the best way to remove a specific row from an Angular Material table that does not have any filters

Here is my samplepage.component.ts code: import { Component } from '@angular/core'; @Component({ selector: 'app-batchticketvalidation', templateUrl: './batchticketvalidation.component.html', styleUrls: ['./batchtic ...

Prevent selecting dates beyond the current date in Formly Datepicker within Angular

How can I disable future dates in Formly with Material datepicker in Angular? Despite searching online, I am unable to find a solution! export class AppComponent { form = new FormGroup({}); model: any = {}; options: FormlyFormOptions = {}; fields: ...

Mastering the Art of Sharing PrimgNg Selected Checkboxes with Child Component Dropdown

I am developing a simple application using PrimeNg. In order to pass information from the selected items of a Multi-Select component in the parent element (<p-multiSelect/>) to a Dropdown component in the child element (<p-dropdown/>), I have i ...

Error message displayed: "There was an issue locating (undefined) and (undefined) while attempting to run Angular-CLI command 'ng g c my-new-component'."

Issue: I'm experiencing a problem in my Angular 5+ app project. When I try to generate a new component in one of my subfolders using the command ng g c my-component, nothing is being generated. Instead, I am encountering some unknown errors. I have a ...

Discover the ultimate strategy to achieve optimal performance with the wheel

How can I dynamically obtain the changing top position when a user moves their mouse over an element? I want to perform some checks whenever the user scrolls up, so I tried this code: HostListener('window:wheel', ['$event']) onWindowS ...

Building a single page web application using TypeScript and webpack - a step-by-step guide

For a while now, I've been working on single page applications using Angular. However, I'm interested in creating a single page application without utilizing the entire framework. My goal is to have just one .html file and one javascript file, w ...

The ReactJS website is encountering issues when attempting to build in AzureDevOps, despite functioning properly

My reactJS App functions properly when run locally, but there are build failures when the same code is built using a pipeline on AzureDevOps. Could someone please explain why this might be happening? Here are the npm run build task logs from the build in ...

Utilizing PrimeNG's p-dataView feature without repetitive FieldSets

Currently, I am utilizing p-dataView and I'm interested in implementing p-fieldset based on the application type. My goal is to prevent the fieldset from being duplicated when multiple instances occur. The scenario below illustrates one such case; how ...

What is the process of assigning attribute values conditionally in Angular 2?

I'm currently exploring Angular 2 and facing a challenge with a basic material input tag. I want to dynamically set its value based on a condition. <md-input value="dataSelected ? {{selectedDataName}} : ''"></md-input> I attemp ...

Executing npm build before or after running npm install

I'm feeling a bit lost when it comes to using npm and could use some guidance... There's a package on npm that caught my eye, called angular-crumbs. I decided to fork the source repository (https://github.com/emilol/angular-crumbs) into my own a ...

The functionality of Angular router is disrupted when guards yield an Observable as their return value

My goal is to redirect users who are not logged in when they try to access protected routes, but I am facing an issue with redirection. The function that checks if the user is logged in returns an Observable. Below is the code snippet from my PrivateGuard ...

Internationalization of deferred-loaded modules within the JHipster application

I created My App using JHipster, which utilizes the JhiLanguageService in the ng-jhipster library. This service relies on the JhiConfigService to configure ngx-translate without requiring manual imports and configuration of the TranslateModule in my app.mo ...

Error alert! A token error has been detected while executing Angular tests under <Jasmine>

I've been navigating the world of Angular testing, but I've hit a roadblock that I can't seem to bypass. Despite my efforts to consult the documentation and scour Google for answers, I remain stuck with a cryptic error message stating "Inval ...

Activate the audit command for the npm enterprise registry

I'd like to know how to activate the npm audit command in my npm enterprise registry. Whenever I attempt to run the npm audit command, I encounter the following error: { "error": { "code": "ENOAUDIT", "summary": "Your configured registry ( ...

constant element within mat-menu in Angular

This coding snippet displays unread notifications to users: <mat-menu #menu="matMenu"> <div class="menu-item" mat-menu-item *ngFor="let item of notifications"> ...item content </div> <b ...

Tips on Resolving TypeError: Unable to Access Undefined PropertyAre you encountering a

I'm currently facing an issue while writing unit test cases using Jest in my Angular project. Whenever I attempt to run my test file, the following errors occur: TypeError: Cannot read property 'features' of undefined TypeError: Cannot read ...