What steps can I take to ensure the reliable functioning of this npm script?

Within my npm package, I have these two straightforward scripts:

"prebuild": "rimraf dist types",
"build": "tsc",

Development dependencies rimraf@^5.0.5 and typescript@^5.3.2 are both installed. However, when I run npm run build, the behavior is inconsistent:

  • The initial execution does nothing, with no errors thrown.
  • If I manually run tsc, it generates the expected build files.
  • Subsequent executions of npm run build work correctly by deleting existing directories and creating new files.
  • However, repeating npm run build fails to generate new build files without any error messages.

I anticipate npm run build to consistently replace existing directories with updated/built files on each execution.

Answer №1

The problem in the project's tsconfig file (@sapphire/tsconfig) was resolved by removing an extension that caused the issue.

This particular extension had enabled the tsBuildInfoFile option, which resulted in generating a tsconfig.tsbuildinfo file during the transpilation process. By including instructions to remove this file using rimraf in the prebuild script, the project now functions correctly as intended.

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

Angular - Collaborative HTML format function

In my project, I have a function that sets the CSS class of an element dynamically. This function is used in different components where dynamic CSS needs to be applied. However, every time I make a change to the function, I have to update it in each compo ...

Encountering notifications and issues pertaining to conflicting dependencies after integrating the angular-oauth2-oidc dependency into the package.json file

I am currently working on an Angular project and wanted to share my package.json file for reference: { "name": "angular.io-example", "version": "0.0.0", "description": "Example project from ...

Using multiple MaterialUI components in a JavaScript page with React can pose challenges

Incorporating multiple MaterialUI Cards in my project, I encountered an issue where all the cards would expand or the select values would change simultaneously. Despite using unique key values and mapped components with distinct keys, the problem persisted ...

React-router-dom PrivateRoute component version 6.8.0

I have created a custom PrivateRoute for my chat app. This is how my PrivateRoute looks: import { useState, useEffect } from 'react'; import { Route, Navigate } from 'react-router-dom'; import axios from 'axios'; interface Pr ...

NodeJS Jest test failing due to a global variable being set for a different test already

I am currently working on a project in TypeScript using Node.js and Jest. I have a function that may or may not modify a global variable, which is a TypeScript Map. After one test modifies the global variable, it retains that value for subsequent tests. I ...

Convert JS datetime to the appropriate ISO format

For a few days now, I have been attempting to save a timestamp from an API call to Postgres using my server-side C# code. When attaching DateTime.Now() to the data transfer object, everything seems to work fine. However, when trying to parse a datetime se ...

Extract values from an object using Typescript

Here is my JavaScript code: const { a, b, c } = { a : "hello", b : "stackoverflow", c : "it's greate" }; I am interested in converting this to TypeScript. Is there any solution for this? ...

The synchronization between Typescript and the HTML view breaks down

I am currently working on an application that retrieves user event posts from MongoDB and displays them in HTML. In the Event-post.ts file, inside the ngOnInit() function, I have written code to retrieve the posts using the postsService.getPosts() method. ...

The 'setComputed' property is not mandatory in the type definition, however, it is a necessary component in the 'EntityExample' type

I'm encountering an issue while trying to create a factory for updating an entity. The error I'm facing is related to the usage of afterload: Entity: import { Entity, PrimaryGeneratedColumn, Column, OneToMany, BaseEntity, AfterLoad, ...

When attempting to pass props to children, Typescript triggers an error message

I am facing an issue with a component that renders a child based on the specific "league" a user is viewing, such as MLB. Typescript is throwing an error because I am not passing the correct props to the child component. However, the parent component has t ...

`How can TypeScript be used to designate the type of a variable within the useState hook?`

I defined a variable called 'text' and a hook named 'setText'. I'm using them to update the value of a form input field. How can I ensure that 'text' is always of type string? This is what I attempted: interface TextInt ...

Running the command "npm run dev" generates a series of files named 0.js, 1.js, all the way up to 14.js within the

As a novice in the realm of Webpack, NPM, and VueJS, I find myself facing a perplexing issue. Despite my efforts to seek answers online, I remain stumped by the outcome when executing the command npm run dev in VueJS - wherein webpack generates 15 files l ...

Is there a way to restrict the type of a discriminated union in Typescript without having to list out all the individual cases explicitly?

As I work extensively with discriminated unions, a common issue arises: When dealing with a function parameter that is a discriminated union type, I often need to perform specific actions based on subsets of the union. Typically, I use the discriminant t ...

Azure DevOps pipeline encounters npm authentication failure

After following the official tutorial on deploying an Angular app to ADO pipelines, I encountered a problem with my yaml file: # Node.js with Angular # Build a Node.js project that uses Angular. # Add steps that analyze code, save build artifacts, deploy, ...

Running pug directly from the local node_modules directory

I'm currently attempting to run pug (/jade) from my node_modules directory, however I am unable to locate the executable within the node_modules/.bin folder. I am running MacOS 10.12.5 and installed pug using the "npm install --save pug" command. Is ...

Can someone explain the process of locating the final data point in d3 and illustrating it using a circle and a line?

https://i.sstatic.net/0AWgj.png I have successfully created a basic line chart in d3. My goal now is to determine the last entry point of the data and draw a circle on it, along with a dotted line similar to the image provided above. Below is my current ...

Encountering "Module ts-jest not found in the transform option" Error During Bazel Testing

In my working Bazel BUILD file, I have set up the following configurations: package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image") load("@npm_bazel_typescript//:index.bzl", "ts_library") # ...

Typescript throws an error when Redux useSelector fails to properly infer the state

Seeking guidance on how to access my state using the useSelector hook import { applyMiddleware, createStore } from 'redux'; import thunk from 'redux-thunk'; import { reducers } from './reducers'; export c ...

Which superclass does ReadonlyArray extend from?

Looking at this TypeScript code snippet: const arr: ReadonlyArray<string> = [ "123", "234" ]; arr.push("345"); An error is thrown by the TS compiler: Property 'push' does not exist on type 'ReadonlyArray<string>&apo ...

live-server does not automatically refresh the page like it should

After installing the live-server package using npm, I noticed that it does not automatically refresh the page when I make changes to CSS files. Although it detects the changes in the CSS files through the terminal, the page itself does not reload. Here ...