Make sure to incorporate the .gitignored files that are compiled from typescript when running the `npm install -g

Looking for a way to ignore the JavaScript files compiled from TypeScript in my git repository to make merging, rebasing, and partial commits easier. Here's how I have it set up:

tsconfig.json

{
    "compilerOptions": {
      "outDir": "./dist"
    }
}

.gitignore

dist

During global installation with these commands:

rm -rf dist
node_modules/.bin/tsc
sudo npm install -g

The dist folder specified in .gitignore is not installed. Is there a more efficient solution? The following workarounds are not ideal:

  • Comment/uncomment the dist line in .gitignore before and after running sudo npm install -g
  • Managing TypeScript and JavaScript files in parallel

Answer №1

After some troubleshooting, I managed to resolve the issue by adding the following code snippet to my package.json:

"files": [
  "/dist"
],

As a result, only the contents of the dist folder and the README.md file are included in the package installation. This helpful tip was discovered while reading a blog post by Jeff Dickey.

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

Unable to locate a type definition file for module 'vue-xxx'

I keep encountering an error whenever I attempt to add a 3rd party Vue.js library to my project: Could not find a declaration file for module 'vue-xxx' Libraries like 'vue-treeselect', 'vue-select', and 'vue-multiselect ...

Encountered an issue when trying to run 'npm install' immediately after running 'npx nuxi init <project name>' in Nuxt 3

Today, when attempting to create a new Nuxt 3 project using npx nuxi init <project name> as usual, I encountered a lengthy error in the terminal while trying to install the dependencies with npm install. Despite deleting the lock file and experimenti ...

Unlock the encrypted information in the blockchain

I've been working on encrypting and decrypting values using Node's built-in crypto module. I found a helpful tutorial that showed me how to encrypt the data, but it didn't provide any sample code for decryption. When I tried using code from ...

Leverage the TypeScript Compiler API to verify whether an interface property signature permits the value of undefined (for example, prop1?:

Currently, I am utilizing the TypeScript Compiler API to extract Interface information in order to generate database tables. The process is functioning effectively, however, I am seeking a method to determine if certain fields are nullable, or as it is phr ...

TypeError: Unable to access the 'classify' property of an object that has not been defined (please save the ml5.js model first)

In my React app, I have set up ml5.js to train a model by clicking on one button and make predictions with another. However, I encounter an error when trying to test the model for the second time: TypeError: Cannot read property 'classify' of und ...

The file path and installed npm package intellisense does not appear in VS Code until I press Ctrl + space for TypeScript

Before pressing ctrl + space, intellisense shows: click here for image description After pressing ctrl + space, intellisense displays: click here for image description Upon updating to vs code version 1.11.0 and opening my project, I encountered an issu ...

What is the most efficient way to execute useEffect when only one specific dependency changes among multiple dependencies?

My main objective is to update a state array only when a specific state (loadingStatus) undergoes a change. Yet, if I include solely loadingStatus as a dependency, React throws an error requesting all dependencies [loadingStatus, message, messageArray, set ...

What is the best way to arrange an array of objects in a descending order in Angular?

private sumArray : any = []; private sortedArray : any = []; private arr1 =['3','2','1']; private arr2 = ['5','7','9','8']; constructor(){} ngOnInit(){ this.sumArray = ...

Tips for executing npm audit with the Task Runner Explorer

I've been struggling to figure out how to adjust my package.json so that I can successfully run npm audit using the Task Runner Explorer by Mad Kirstensen within Visual Studio (Professional 2017). In my package.json, it starts with: { "version": " ...

Can you explain the distinction between Observable<ObservedValueOf<Type>> versus Observable<Type> in TypeScript?

While working on an Angular 2+ project in Typescript, I've noticed that my IDE is warning me about the return type of a function being either Observable<ObservedValueOf<Type>> or Observable<Type>. I tried looking up information abou ...

Every time I attempt to install a package, npm consistently encounters an error

Every time I attempt to install vue.js or bulma, npm encounters an error. Can someone please provide assistance? Error:" └── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294b5c4544486919071d0718">[email protect ...

Troubleshooting: Resolving JSX props issue in Vue template

Ever since integrating the FullCalendar library into my Vue project, I've been encountering an error every time I try to use my custom component in a Vue template. My setup includes Vue 3, Vite, VSCode, eslint, and prettier. This issue seems to be m ...

How to execute a function in a child component that is declared in the parent component using Angular

Is anyone able to help me with an issue I am facing in my Angular project? I have two components, 'app' and 'child'. Within the child component, I have a button that calls a function defined in the app component. However, this setup is ...

npm: Installation of Git repository as a package is unsuccessful

I recently made modifications to a Git repository and attempted to install it using npm i {repo name}. Initially, I believed the installation was successful. // package.json "react-big-calendar": "git+https://github.com/seanprpl/fkCalendar ...

Is there a way to turn off TypeScript Inference for imported JavaScript Modules? (Or set it to always infer type as any)

As I attempt to utilize a JS module within a TypeScript File, I encounter errors due to the absence of type declarations in the JS module. The root cause lies in a default argument within the imported JS function that TypeScript erroneously interprets as ...

Determine parameter types and return values by analyzing the generic interface

I am currently working on a feature where I need to create a function that takes an interface as input and automatically determines the return types based on the 'key' provided in the options object passed to the function. Here is an example of ...

Why is it that TypeScript does not issue any complaints concerning specific variables which are undefined?

I have the following example: class Relative { constructor(public fullName : string) { } greet() { return "Hello, my name is " + fullName; } } let relative : Relative = new Relative("John"); console.log(relative.greet()); Under certain circum ...

Using onDoubleClick with MUI TextField: A Quick Guide

Whenever the user double clicks the input field, I would like to automatically select the text. I have created a function for this specific action: export const selectText = ( event: React.MouseEvent<HTMLInputElement | HTMLTextAreaElement, MouseEvent& ...

Using `npm audit --force` is advised only for those with expertise. If you are unsure, what steps should you take? Could my application be vulnerable while

As a newcomer to Angular, I recently ran into the usual warnings when executing npm install: found 42 vulnerabilities (40 moderate, 2 high) run `npm audit fix` to fix them, or `npm audit` for details After running npm audit fix, only a few vulnera ...

Public external requirement

Is there a proper way to utilize external dependencies with pub? Specifically, I am interested in incorporating Materialize-css and utilizing it in my scss file. When installing it via npm, pub seems unable to locate it in the node_modules folder. Placing ...